How to set the value of <input type = "hidden"> in asp.net page_load without using runat = "server"
I need to do the following two things ...
- I want to set the value in asp.net page_load. the problem is that I do not want to use runat = "server". I tried this following but this does not work:
HtmlInputHidden hiddenControl = (HtmlInputHidden) FindControl ("a");
is there any way to access asp.net page_load without using runat = "server" ??
- I can do this if I use, but in this case I cannot access it in the javascript function of the main page. I tried this, but it does not work ...
- var hdnField = document.getElementById ('<% = hdnIdentity.ClientId%>');
- var hdnField = document.getElementById ("hdnIdentity"). getAttribute ("value");
- var hdnField = document.getElementById ("hdnIdentity"). Value
what i need ... I want to access the hidden value of the content of the page in javascript on the main page. is there any way ??? thnx pre-reviews Haroon haroon426@yahoo.com
I sometimes do the following, especially when I want to control my identifiers (especially when using jquery).
<asp:literal id="literal1" runat="server"><input type="hidden" id="someid" value="{0}"/></asp:literal>
Then in the code you can set the value with the following:
literal1.Text = string.Format(literal1.Text, "somevalue");
It cannot do without using runat = "server", but you did not indicate why you do not want to do this. In addition, you need to get the value using request.form
Update
.net 4.0 . . :
http://weblogs.asp.net/asptest/archive/2009/01/06/asp-net-4-0-clientid-overview.aspx