Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 27, 2006 07:32 PM by James Steele
Apr 27, 2006 05:59 PM|LINK
Hi friends, I did a webform with textboxes and I'm with the folowing problems:
textbox name: txtNome
BEFORE: error: the "txtNome" does not exist in the current context
Then I did put the code in the "code-behind":
protected System.Web.UI.WebControls.TextBox txtNome;
AFTER: error: CS0102: The type '_Default' already contains a definition for 'txtNome'
Please help me! Thanks
Apr 27, 2006 07:32 PM|LINK
Your webform should have declarative code for the textbox that looks like line 1 or line 2:
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
<input id="txtName2" type="text" runat="server" />
Me.txtName.Text = "James Steele"
Me.txtName2.Value = "James Steele2"
There is no need for you to declare the textbox in the code behind. The code declaration for the texbox is created automatically by the runtime when the aspx page is parsed.
May I suggest that you have a look at
this article which explains the process in detail and should help clarify things for you.
Let me know how you make out!