Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
Dear All

I added a textbox control in my ABC.aspx, the code is like this
<input id="txtSessionKey" name="txtSessionKey" type="text" value=""/>

Then I tried to give it a value in the ABC,aspx.cs, the code is
txtSessionKey.Value = "123";

However, when I compiled, I got this error:
Error 2 The name 'txtSessionKey' does not exist in the current context

I am quite new in .NET area.

please help me if anyone has solved this problem before.

Thank you
Posted
Updated 8-Jul-11 1:14am
v2
Comments
shefeekcm 8-Jul-11 7:09am    
can you share the aspx page
Slacker007 8-Jul-11 7:15am    
Edited for readability and formatting.

In order for any item in your aspx file to be visible to the code behind you have to tag it with runat="server" and recompile. It should be all you need to do.
 
Share this answer
 
Comments
Espen Harlinn 8-Jul-11 7:30am    
Right, my 5
Baji Jabbar 8-Jul-11 8:38am    
yes absolutely. My 5 too
Hi
if you write like below it only availabe on client browser means u can call this control by using client script(javascript/jQuery) but not in C# .cs file



but if you want to access the control from C# .cs file u have to use runat attribute . if you runat="SERVER"




thanks
Faisal
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900