You are currently viewing MVC, IIS, CSS, Notes

MVC, IIS, CSS, Notes

MVC (section 1)

 

TempData Usage

TempData : https://stackoverflow.com/questions/21454232/asp-net-mvc-how-to-pass-full-model-from-view-to-controller

Using the code below you can send data back and forth from controller to view and view to controller.

TempData["savedControl"] = "Successful"; // Set the value for your TempData

TempData.Peek("savedControl"); //View the data while retaining it
string SavedStatus = (string)TempData.Peek("savedControl");// saving the value requires un-boxing

Viewdata vs Viewbag vs tempdata:

Peek: https://hassantariqblog.wordpress.com/2016/09/02/mvc-when-to-use-keep-vs-peek-in-asp-net-mvc/

or Keep? : https://stackoverflow.com/questions/2642062/asp-net-mvc-does-browser-refresh-make-tempdata-useless

Pass Model or View Variables to JQuery/Javascript function : 

For thoroughness, I came across another solution which was part of the functionality introduced in version 1.4.3 of the jQuery click event handler.

It allows you to pass a data map to the event object that automatically gets fed back to the event handler function by jQuery as the first parameter. The data map would be handed to the .click()function as the first parameter, followed by the event handler function.

Here’s some code to illustrate what I mean:


        // say your selector and click handler looks something like this...
        $("some selector").click({param1: "Hello", param2: "World"}, cool_function);
        
        // in your function, just grab the event object and go crazy...
        function cool_function(event){
            alert(event.data.param1);
            alert(event.data.param2);
        }

I know it’s late in the game for this question, but the previous answers led me to this solution, so I hope it helps someone sometime!

Resource: https://stackoverflow.com/questions/3273350/jquerys-click-pass-parameters-to-user-function

Action & Actionlink from view (Razor)

@foreach(var report in Model.ListofTemplates)
{
@Html.ActionLink(report.Name,"EditReport","Admin",new { id = report.TemplateID},null)

}

IIS (section 2)

Attaching to a process with Visual Studio debugger:  find the  w3w.ex process


 

CSS (section 3)

Remove/reset style from element: “Unset” : https://stackoverflow.com/questions/8228980/reset-css-display-property-to-default-value