web form user control best practices?

N

noname

i have a few user controls that need a "visible" property. one example is
an error box. the error box's visible property would only be set in the
event of an error, of course. i've come up with two methods to do this,
neither of which seem optimal.

1. user control consists of simply a single <asp:label>. all output - be
it table tags, row tags, etc. - is set to the label's text property when the
user control's visible property is true.

2. user control consists of a few <asp> control - labels, text boxes,
etc. - and when the user control's visible property is set or reset i do the
same for each <asp> control.

(1) has the funny feeling of how one programs in regular old ASP. (2)
doesn't allow other non ASP.NET content because normal <html> tags can't be
turned on and off like <asp> controls.

i'd like to do something like the following and still have the entire
thing's visibility togglable:

<%@ control codebehind="foo.cs" ... %>
<table>
<tr>
<td><asp:label id="lblFoo" runat="server">Foo</asp:label></td>
<td><asp:textbox id="txtFoo" runat="server"></asp:textbox></td>
</tr>
</table>

now, to be able to turn the <table> output on or off too ...

thanks for any help!
noname
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top