CS0102: The type '_Default' already contains a definition for 'txtNome'

Last post 04-27-2006 3:32 PM by James Steele. 1 replies.

Sort Posts:

  • CS0102: The type '_Default' already contains a definition for 'txtNome'

    04-27-2006, 1:59 PM
    • Member
      10 point Member
    • pablodarde
    • Member since 04-26-2006, 2:57 PM
    • Posts 2

    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

  • Re: CS0102: The type '_Default' already contains a definition for 'txtNome'

    04-27-2006, 3:32 PM
    • Participant
      875 point Participant
    • James Steele
    • Member since 04-26-2006, 8:08 PM
    • Posts 173

    Hi pablodarde,

    Your webform should have declarative code for the textbox that looks like line 1 or line 2: 

    1    <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
    2    <input id="txtName2" type="text" runat="server" />
        
     In your code behind page you can reference the controls as follows: 
    1    Me.txtName.Text = "James Steele"
    2    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!

    James Steele

Page 1 of 1 (2 items)