M
Manny
Hello Folks,
I am having an issue with retrieving value of hidden field in the
codebehind. The value of the control is set using Javascript defined in the
Page Load Event. I have tried putting the code in the Page Init to without
any results. Could someone please assist?
Code Snippet:
<input id="hdnTextBoxData" name = "hdnTextBoxData" type="hidden"
runat="server" />
if (!(Page.IsPostBack))
{
try
{
if (Request.QueryString["edit"].Equals("1"))
{
string script = "<script
type=\"text/javascript\">document.form1.hdnTextBoxData.value =
window.opener.document.getElementById('hdnTxt1').value;";
script += " alert(document.form1.hdnTextBoxData.value);";
script += "</" + "script>";
this.Page.ClientScript.RegisterStartupScript(Page.GetType(), "scr", script);
}
}
catch (Exception ex) { }
}
If you review the code, I have one liner with Alert showing the Value of the
Hidden Field which works fine. However when I write
Response.Write(hdnTextBoxData.Value), it returns an empty string.
Thanks
Manny
I am having an issue with retrieving value of hidden field in the
codebehind. The value of the control is set using Javascript defined in the
Page Load Event. I have tried putting the code in the Page Init to without
any results. Could someone please assist?
Code Snippet:
<input id="hdnTextBoxData" name = "hdnTextBoxData" type="hidden"
runat="server" />
if (!(Page.IsPostBack))
{
try
{
if (Request.QueryString["edit"].Equals("1"))
{
string script = "<script
type=\"text/javascript\">document.form1.hdnTextBoxData.value =
window.opener.document.getElementById('hdnTxt1').value;";
script += " alert(document.form1.hdnTextBoxData.value);";
script += "</" + "script>";
this.Page.ClientScript.RegisterStartupScript(Page.GetType(), "scr", script);
}
}
catch (Exception ex) { }
}
If you review the code, I have one liner with Alert showing the Value of the
Hidden Field which works fine. However when I write
Response.Write(hdnTextBoxData.Value), it returns an empty string.
Thanks
Manny