yolip
May 21st, 2007, 08:18 AM
Hi all,
I am building a asp.net (vb.net) web application, however, i found it so hard to build friendly interface. In ASP, i can just generate a form and write it to the screen easily, then retrieve the value by using request.form or request.querystring etc, but ASP.NET, I did not same thing but doesn't works. for example: i use the code below, it did generate the table with controls and displayed in the page, but i can't find any way to get the value from generated control. e.g a value from a textbox called "txtquestion". Anyone know the way to do it? or I have to change to the other way? Please teach me how?
Thanks
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim strOutput As New StringBuilder
strOutput.Append("<table id style=""width: 450px"">")
strOutput.Append(SampleFunc(datatable))
strOutput.Append("</table>")
Response.Write(strOutput)
End Sub
Public Function SampleFunc(ByVal Ds As DataTable) As String
'typeid = 1
Dim strResult As New StringBuilder
Dim iCount As Integer
strResult.Append("<tr>")
strResult.Append("<td colspan=""3"" style=""width: 450px"">")
strResult.Append(Ds.Rows(0)("Question"))
strResult.Append("</td>")
strResult.Append("</tr>")
strResult.Append("<tr>")
strResult.Append("<td colspan=""3"" style=""width: 450px; height: 7px"">")
For iCount = 0 To Ds.Rows.Count - 1
strResult.Append(Ds.Rows(iCount)("AnswerNum") & ")")
'strResult.Append("<asp:TextBox ID=" & Ds.Rows(iCount)("Question_ID") & "_" & Ds.Rows(iCount)("AnswerNum") & " runat=""server""></asp:TextBox><br />")
strResult.Append("<input ID=" & Ds.Rows(iCount)("Question_ID") & "_" & Ds.Rows(iCount)("AnswerNum") & " type=""text"" /><br />")
'<input id="Text1" type="text" />
Next
strResult.Append("</td>")
strResult.Append("</tr>")
strResult.Append("<tr>")
strResult.Append("<td colspan=""3"" style=""width: 450px; height: 5px"">")
strResult.Append("</td>")
strResult.Append("</tr>")
Return strResult.ToString
End Function
I am building a asp.net (vb.net) web application, however, i found it so hard to build friendly interface. In ASP, i can just generate a form and write it to the screen easily, then retrieve the value by using request.form or request.querystring etc, but ASP.NET, I did not same thing but doesn't works. for example: i use the code below, it did generate the table with controls and displayed in the page, but i can't find any way to get the value from generated control. e.g a value from a textbox called "txtquestion". Anyone know the way to do it? or I have to change to the other way? Please teach me how?
Thanks
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim strOutput As New StringBuilder
strOutput.Append("<table id style=""width: 450px"">")
strOutput.Append(SampleFunc(datatable))
strOutput.Append("</table>")
Response.Write(strOutput)
End Sub
Public Function SampleFunc(ByVal Ds As DataTable) As String
'typeid = 1
Dim strResult As New StringBuilder
Dim iCount As Integer
strResult.Append("<tr>")
strResult.Append("<td colspan=""3"" style=""width: 450px"">")
strResult.Append(Ds.Rows(0)("Question"))
strResult.Append("</td>")
strResult.Append("</tr>")
strResult.Append("<tr>")
strResult.Append("<td colspan=""3"" style=""width: 450px; height: 7px"">")
For iCount = 0 To Ds.Rows.Count - 1
strResult.Append(Ds.Rows(iCount)("AnswerNum") & ")")
'strResult.Append("<asp:TextBox ID=" & Ds.Rows(iCount)("Question_ID") & "_" & Ds.Rows(iCount)("AnswerNum") & " runat=""server""></asp:TextBox><br />")
strResult.Append("<input ID=" & Ds.Rows(iCount)("Question_ID") & "_" & Ds.Rows(iCount)("AnswerNum") & " type=""text"" /><br />")
'<input id="Text1" type="text" />
Next
strResult.Append("</td>")
strResult.Append("</tr>")
strResult.Append("<tr>")
strResult.Append("<td colspan=""3"" style=""width: 450px; height: 5px"">")
strResult.Append("</td>")
strResult.Append("</tr>")
Return strResult.ToString
End Function