Parser Error

Discussion in 'ASP .Net Web Controls' started by Emmweb, Apr 7, 2005.

  1. Emmweb

    Emmweb Guest

    I am relatively new to the whole .NET environment. If I am posting this to
    the wrong newsgroup, I apologize; please direct me.

    Could anyone point me in the right direction for finding my error in the
    following code? The error I get is a Parser Error on the line that starts
    <asp:Text.... The exact message says "'Title(0)' is not a valid identifier.

    for i=0 to (Title.Length - 1)
    Title(i).Text = " "
    Author(i).Text = ""
    Next
    ....
    <asp:TextBox id="Title(0)" runat="server" size = "50"></asp:TextBox>


    Thanks!
    Emma
    Emmweb, Apr 7, 2005
    #1
    1. Advertising

  2. Emmweb

    Brock Allen Guest

    > <asp:TextBox id="Title(0)" runat="server" size =
    > "50"></asp:TextBox>


    You assign Title(0) as the ID, which is invalid. Just do ID="Title".

    > for i=0 to (Title.Length - 1)
    > Title(i).Text = " "
    > Author(i).Text = ""
    > Next


    I'm not sure what this is trying to accomplish. If you want to blank out
    the value of the TextBox control, just use the variable (from the ID above):

    Title.Text = ""

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen
    Brock Allen, Apr 7, 2005
    #2
    1. Advertising

  3. Emmweb

    Emmweb Guest

    We're trying to create an array, using the for...next loop to initialize the
    array values. Which was why we had Title(0), to call the first value of
    Title. Does that help?

    "Brock Allen" wrote:

    > > <asp:TextBox id="Title(0)" runat="server" size =
    > > "50"></asp:TextBox>

    >
    > You assign Title(0) as the ID, which is invalid. Just do ID="Title".
    >
    > > for i=0 to (Title.Length - 1)
    > > Title(i).Text = " "
    > > Author(i).Text = ""
    > > Next

    >
    > I'm not sure what this is trying to accomplish. If you want to blank out
    > the value of the TextBox control, just use the variable (from the ID above):
    >
    > Title.Text = ""
    >
    > -Brock
    > DevelopMentor
    > http://staff.develop.com/ballen
    >
    >
    >
    >
    >
    >
    >
    Emmweb, Apr 7, 2005
    #3
  4. Emmweb

    Brock Allen Guest

    You can't declaratively declare an array of controls in ASP.NET. I presume
    you're trying to do what you used to do in VB6? You can dynamically create
    them, though, in your code[behind]. So call "new TextBox()" and then add
    that control under some other control in the page. So if you had a PlaceHolder,
    then you'd do myPlaceHolder.Controls.Add(theTextBoxIJustCreated).

    Sorry for the terse post (long day).

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > We're trying to create an array, using the for...next loop to
    > initialize the array values. Which was why we had Title(0), to call
    > the first value of Title. Does that help?
    >
    > "Brock Allen" wrote:
    >
    >>> <asp:TextBox id="Title(0)" runat="server" size =
    >>> "50"></asp:TextBox>

    >> You assign Title(0) as the ID, which is invalid. Just do ID="Title".
    >>
    >>> for i=0 to (Title.Length - 1)
    >>> Title(i).Text = " "
    >>> Author(i).Text = ""
    >>> Next

    >> I'm not sure what this is trying to accomplish. If you want to blank
    >> out the value of the TextBox control, just use the variable (from the
    >> ID above):
    >>
    >> Title.Text = ""
    >>
    >> -Brock
    >> DevelopMentor
    >> http://staff.develop.com/ballen
    Brock Allen, Apr 8, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bernd Oninger
    Replies:
    0
    Views:
    740
    Bernd Oninger
    Jun 9, 2004
  2. ZOCOR

    XML Parser VS HTML Parser

    ZOCOR, Oct 3, 2004, in forum: Java
    Replies:
    11
    Views:
    794
    Paul King
    Oct 5, 2004
  3. Bernd Oninger
    Replies:
    0
    Views:
    796
    Bernd Oninger
    Jun 9, 2004
  4. Sean
    Replies:
    3
    Views:
    246
    robic0
    Oct 3, 2006
  5. Sean
    Replies:
    0
    Views:
    352
Loading...

Share This Page