Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Controls (http://www.velocityreviews.com/forums/f63-asp-net-web-controls.html)
-   -   Parser Error (http://www.velocityreviews.com/forums/t775831-parser-error.html)

Emmweb 04-07-2005 02:07 PM

Parser Error
 
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


Brock Allen 04-07-2005 04:42 PM

Re: Parser Error
 
> <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 04-07-2005 05:49 PM

Re: Parser Error
 
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 04-08-2005 12:34 AM

Re: Parser Error
 
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






All times are GMT. The time now is 09:46 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.