Need a clean solution to an asp Select case issue

W

William Gower

I have a situation where I will display text boxes and labels depending on
the user type of the user using this form. In the asp version I used a
select case, but in the .net version I am putting all the code in the .vb
file. i don't want any code on the aspx page so how can do I this?

Select case usertype
case 1:
<input type=textfield name="TextField1" >
case 2:
<input type=textfield name="TextField2">
case 3:
<input type=textfield name="TextField3">
end case
 
J

Jeff

One way: From the code-behind, you can set the .Visible property of each
textbox control (TextField1.Visible = false;) or whatever. Setting the
visible property to false causes no HTML to be rendered to the browser for
the control. You could still have a SELECT CASE control which textboxes are
visible (or a switch structure in C#)... you're just executing it from your
code-behind.

HTH
 
M

Matt Berther

Hello William,

TextBox tb = new TextBox();

Select case usertype
case 1:
tb.Id = "TextxField1";
case 2:
tb.Id = "TextxField3";
case 3:
tb.Id = "TextxField3";
end case

this.Controls.Add(tb);
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top