Dynamically change the value of the hidden field

advertisements

For an existing site, I have to pass values in hidden fields from a form that's loaded by different pages (eg. City1.aspx, City2.aspx, City3.aspx, etc.), but they are loaded inside an iframe. I also have to dynamically change the value of at least one of those hidden field (let's call it "source") based on the city page loading it. I am familiar with PHP and JavaScript/JQuery, but I have no idea how to do this in C#.

I've found tutorials on retrieving the file name (sans extension) via JavaScript. I think I can still get the city even if the form is in an iframe, but I'd like to keep to the site's conventions and use C# if possible.

Code snippets or links to possible solutions would be much appreciated.


if you want modify the value of your input in c# associated to your aspx (Code behind), you must to add attributes runat=server to your input.

use this code in your aspx

<input id="test" type="hidden" runat="server"/>

and in your c#

test.Value = 123; //your value is 123 for example