Heya folks, I'm trying to learn .Net and have run into a snag when it comes to adding and databinding controls on a web form.<BR><BR>In classic asp I did this<BR><code> MyVar = dCmdSelect.Fields("Control_type")<BR> Select Case MyVar<BR> Case "0" ' one line text<BR> %><td><input type="text" size="26" maxlength="256" name="<% Response.write(dCmdSelect.Fields("Control_Name")) %>"></td><% <BR> Case "1" 'textarea<BR> %><td><textarea name="<%Response.Write(dCmdSelect.Fields("Control_Name")) %>" rows="5" cols="42"></textarea></td><%<BR> Case "2" 'checkbox<BR> %><td><input type="checkbox" name="<%Response.Write(dCmdSelect.Fields("Control_Name")) %>" value=http://aspmessageboard.com/archive/index.php/"yes"></td><%</code><BR><BR>What that allowed me to do was to look up a table that had a listing of what control was needed, the variable name, and farther down in the case select that I haven't shown are values for different options (yes , no, maybe, 1,2,3,4,5 and so on)<BR><BR>This allowed me to make a form Builder that when run would dynamically create a form for an end user not versed in coding.<BR><BR>How would I do the same in .Net? Will I be able to loop thru a case select and build a control set? Are the controls and their use the same as in ASP? or did they move to a VB modal?<BR><BR>I realize this is probably a basic Question, but other than a "Hello world" app or two, I have not done anything in .Net .<BR>Thanx!Something to consider in .net, you are dealing with a mix of asp technologies (that being session object, server object and so on) and application technologies (if you are in vb.net this means lables, panels and the ability to show/hide).<BR><BR>In this case instead of writing out the actual html for form objects you could add <asp:textbox id=idname runat=server> and have programmatic access to that web form control. By that I mean now you can do:<BR><BR>Select case var<BR> case 1<BR> idname.text = "whatever"<BR> idname.visible = true<BR> otherid.visible = false<BR> case 2<BR> idname.visible = false<BR> otherid.visible = true<BR> otherid.text = "the second whatever"<BR> case else<BR> otherid.visible = false<BR> idname.visible = false<BR>end select<BR><BR>Have fun!I appreciate the quick reply.<BR><BR>This is where my lack oF non web programming is hampering me I guess..LOL<BR><BR>With that method, would I have to essentially build the form first and hide the controls?<BR><BR>What I need is a bit more dynamic then that - the end user wants let's say, fifteen questions with radio answers of yes and no.<BR><BR>another user wants a mixture of text boxes, check boxes, and textareas on his form.<BR><BR>I came up with looping thru a recordset and using the select case to have one form process multiple types of forms. Is this process you showed me similiar to that?<BR><BR><BR><BR>Are you using visual studio.net? If so, then you can drag and drop the web form controls from your toolbar to your page. Once they are there then you can open your page.aspx.vb and have programmatic access to the controls.Yes, I am using VS.Net, but I think there is a miscommunication going on here.<BR><BR>I have to build an application that will allow a non programmer to create a survey with choices of what controls to use - check boxes, radio buttons, text and so on.<BR><BR>The users choices would then be saved to a database. Then another page with a loop would read the database and dynamically create the form for use.<BR><BR>I solved that in classic asp by just saving a number for what control they wanted<BR>0 = text<BR>1 = checkbox<BR>2 = textarea <BR>and so on.<BR><BR>So the recordset would return the question, what control was needed, what the variable name was to be, and a host of other things.<BR><BR>So, as the form looped thru the recordset, a survey is built.<BR><BR>My recordset would be<BR>Q1, Control 0, Varname=A<BR>Q2, Control 2, Varname=B<BR>Q3, Control 0, Varname=C<BR><BR>My Loop would return = <BR><p>Q1?</p><BR><td><input type="text" size="26" maxlength="256" name="A"></td><BR><p>Q2?</p><BR><td><textarea name="B" rows="5" cols="42"></textarea></td><BR><p>Q3?</p><BR><td><input type="text" size="26" maxlength="256" name="C"></td><BR><BR>Does that make sense?I understand where you are coming from, I had a simular situation. All I was getting at is that instead of adding html form elements you can dynamically add web form controls:<BR>in your aspx page you need something like a panel to add the controls to and control where they show up on the page. Once you have that, in your .vb page:<BR><BR><BR> Dim tb As New System.Web.UI.WebControls.TextBox()<BR>tb.text = "text"<BR>tb.cssclass = "classname"<BR>'other stuff can go here too. then when you have it built:<BR>panel.controls.add(tb)<BR><BR>You can do that all day long
Thank you for your time.<BR><BR>At least I have a direction to go now!
