How can I convert
$("#myChildTabName").load("./MyController/MyMethod/" + myParameter);
to use @url.Action ?
MyMethod returns a PartialView. Basically I am I want to load a partial view upon click on the Tab.
Update as below:
I have figured out a solution as below, but this is giving an error saying that applicationID does not exist in the current context. An alert just above the jQuery call does display applicationID.
//The below code DOES NOT work.
function LoadTabContents(applicationID)
{
$("#currentTab").load('@Url.Action("TabMethod", "MyController", new { @id = applicationID })')
}
//The below code works fine.
function LoadTabContents(applicationID)
{
$("#currentTab").load('@Url.Action("TabMethod", "MyController", new { @id = 123})')
}
I am afraid what you are trying to do cannot be done all via Razor. The applicationID must be appended client side since only the client knows the real value. You can try something like this:
The URL.Action will generate the right path and the rest will append the parameter phased to the JavaScript function. Some fiddling must be done with the slashes since I cannot remember if the URL.action will append one or not…