Url.Action("actionName","ControllerName",new { extraData = getdata()});
getdata() is a javascript funcion and I want to use it like
public ActionResult actionName(string extraData)
{
*/ bla /*
}
Has anyone any Idea?
Javascript is client side and C# is server side so that is not going to work. It looks like you're using MVC, so why not create a route for this situation? Then the url can be manipulated with javascript on the client, and your server code remains the same.
routes.MapRoute(
"newRoute", // Route name
"NewRoute/{extraData}", // URL with parameters
new
{
controller = "ControllerName",
action = "ActionName",
extraData = string.Empty
}
);
Then on the client you may have a link as below:
<a id="myLink" href="about:blank">My Link</a>
And you can use your javascript to manipulate this link as required:
document.getElementById("myLink").href = "/NewRoute/" + getData();
I've had to make many assumptions here, so if this doesn't answer your question then you might need to add a little more detail about what you're trying to do.
getdatawill be executed and its result will be passed via the variableextraDatato your controller...