Hi,
how to pass Javascript value to controler in mvc archicture?
I am pass value in this types
location.href = "Home/Delete/" + idval;
In my Controler i get the value of "idval" ..........
any query regarding my question please revert me...
Thanks,
Jitenra Patel
How to pass value javascript to controler in mvc in asp.net?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Amit ChoudharyRank #145 · 15.8K reputationPosted Mar 4, 2010, 3:52 AM EST
below is a samjple of using javascript value to code behind or server side:
script type="text/javascript"> function abc() { var str="value"; document.getElementById("Hidden1").value=str; } script> body> form id="form1" runat="server"> div> input id="Hidden1" type="hidden" runat="server" /> asp:Button ID="Button1" runat="server" OnClientClick="abc()" Text="Button" onclick="Button1_Click" /> div> form> body>Code Behind:
But you should pay attention on the order of setting the variable to Hidden control in JavaScript and retrieving the value of Hidden control in aspx page. In the same event handle, it needs execute the Client first. For example, OnClientClick="abc()" will be executed before onclick="Button1_Click". Otherwise, you will get the empty.
Hope you get some idea from Here.Please mark as answer if it helps you.