Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

hello i'm trying to dynamically add a tag to an aspx page.

 

i add labels at runtime using myPanel.Controls.Add(myLabel), and would like to insert "<BR>" between them, to space my data.

 

what object/method should i use ? HtmlTextWriter ? how does that work ?

 

thanx,

 

Huby.

there are 10 kinds of people on earth:

those who understand binary, and those who don't.

Posted

ok thank you !

 

sorry i know it was a newbie question, but i'm getting into ASP.NET without asy classic ASP background...

 

LiteralControl is easy enough :D i used this syntax :

ExpoPanel.Controls.Add(new LiteralControl("<BR>"));

is that the shortest/most optimized way of using it ?

 

thank you for the reply ;)

 

Huby.

there are 10 kinds of people on earth:

those who understand binary, and those who don't.

Posted
ok thank you !

 

sorry i know it was a newbie question, but i'm getting into ASP.NET without asy classic ASP background...

 

LiteralControl is easy enough :D i used this syntax :

ExpoPanel.Controls.Add(new LiteralControl("<BR>"));

is that the shortest/most optimized way of using it ?

 

thank you for the reply ;)

 

Huby.

and i'll just add...

 

that if you are indeed just learning ASP.NET... learning the "shortcut" methods might be hurting you, not helping you... since the "long way" will teach/show you whats going on other than "it just works" (this holds true for me anyways)

 

So like:

 

'Create a new control that holds a line break

Dim litLineBreak As New Literal

litLineBreak.Text = "<br />"

 

'Now add it to the Panel

myPanel.Controls.Add(litLineBreak)

 

 

and with the above, later on you can just re-use "litLineBreak" if you need to add another line break somewhere instead of unceccarily created "New" controls every time

 

hth

If you make it idiot proof, they'll build a better idiot :-)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...