Home All Groups Group Topic Archive Search About

create webcontrols in aspx or aspx.cs

Author
22 Sep 2006 2:52 PM
brown
Is it best to always put the webcontrols in the aspx file or is it sometimes
better to create them (new) in the code behind? I see the standard/easiest
way is to place them in the aspx, but are there common situations where your
output is conditional and it's better to just do it in the aspx.cs file?

Author
23 Sep 2006 6:05 PM
Brennan Stehling
When you want to have a control shown or hidden depending on a certain
context you can set the Visible property of your controls.

Normally what I do is wrap multiple controls within a Panel or
PlaceHolder control and set the Visible property as needed.  You may
also want to look at the MultiView and Wizard controls.  Those provide
automatic show/hide functionality with added features.

Brennan Stehling
http://brennan.offwhite.net/blog/

brown wrote:
Show quoteHide quote
> Is it best to always put the webcontrols in the aspx file or is it sometimes
> better to create them (new) in the code behind? I see the standard/easiest
> way is to place them in the aspx, but are there common situations where your
> output is conditional and it's better to just do it in the aspx.cs file?
Author
23 Sep 2006 11:24 PM
brown
Thanks for your feedback!
Do you use the Table webcontrol or just put the webcontrols inside
unscripted <table><tr><td> tags in the aspx file?
I'm thinking try the latter. Just interested in what experienced .net
developers approach is to formatting the webcontrols on the page.

Show quoteHide quote
"Brennan Stehling" <offwh***@gmail.com> wrote in message
news:1159034750.246264.83580@m73g2000cwd.googlegroups.com...
> When you want to have a control shown or hidden depending on a certain
> context you can set the Visible property of your controls.
>
> Normally what I do is wrap multiple controls within a Panel or
> PlaceHolder control and set the Visible property as needed.  You may
> also want to look at the MultiView and Wizard controls.  Those provide
> automatic show/hide functionality with added features.
>
> Brennan Stehling
> http://brennan.offwhite.net/blog/
>
> brown wrote:
> > Is it best to always put the webcontrols in the aspx file or is it
sometimes
> > better to create them (new) in the code behind? I see the
standard/easiest
> > way is to place them in the aspx, but are there common situations where
your
> > output is conditional and it's better to just do it in the aspx.cs file?
>