Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

My control names get changed at runtime

Status
Not open for further replies.

VBRookie

Programmer
May 29, 2001
331
US
This is a problem because how can I reference the control in the code behind file if it has changed at runtime. Example:


In the aspx file I have the following control:

Code:
<input type=&quot;hidden&quot; id=&quot;EnterHit&quot; value=&quot;N&quot; runat=&quot;server&quot; />

In my code-behind file I have the following code:

Code:
protected System.Web.UI.HtmlControls.HtmlInputHidden EnterHit;

private void Page_Load(object sender, System.EventArgs e)
		{
           if (EnterHit.Value == &quot;Y&quot;)
			{
				... some code here
			}
         }

I also have a javascript routine that changes the value of the hidden variable if the enter key is pressed. It is:

Code:
<script language=javascript>
function FindKey(){
if (event.keyCode == 13) {document.frmMain.EnterHit.value='Y';}
}
</script>


I get an error that says:

Microsoft JScript runtime error: 'document.frmMain.EnterHit' is null or not an object


Can someone please point me in the right direction?

- VBRookie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top