S
sean
Hi There,
I am trying to display some textboxes on my page, When I run the code the
textbox is written to the page (when I view source) but not to the screen.
Could someone tell me if I have the syntax correct?
Sean - thanks in advance for your answer
!-- code
response.write ("<asp:TextBox runat=server id=" & strMFormValue &"
/></td></tr>" & Vbcrlf)
<% @Import Namespace="System.Data" %>
<% @Import Namespace="System.Data.SqlClient" %>
<script language="vb" runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
If Not Page.IsPostBack then
BindData()
End If
End Sub
Sub BindData()
Dim dbRead As SqlDataReader
Dim strMFormControl as string
Dim strMFormValue as string
Dim strMDFormControl as string
Dim strMDFormValue as string
Dim myConnection as New
SqlConnection(ConfigurationSettings.AppSettings("connectionString"))
try
myConnection.Open()
Dim myCommand As New SqlCommand("GetFormById", myConnection)
myCommand.CommandType = CommandType.StoredProcedure
dbRead = myCommand.ExecuteReader()
While dbRead.Read ( )
strMFormValue = dbRead(1)
strMFormControl = dbRead(2)
strMDFormValue = dbRead(3)
strMDFormControl = dbRead(4)
response.write ("<form runat=server><table border=1 align=center>" &
Vbcrlf & _
"<tr><td colspan=2>" & dbRead(0) & "</td></tr>" & Vbcrlf & _
"<tr><td>" & strMFormValue & "</td><td>" & Vbcrlf)
DisplayFormItem(strMFormControl,strMFormValue)
response.write ("<tr><td>" & strMDFormValue & "</td><td>" & Vbcrlf)
DisplayFormItem(strMDFormControl,strMDFormValue)
response.write ("</table></form>")
End While
dbRead.close
Catch oexpData As OleDb.OleDbException
response.write ("an exception has occured,")
response.end
Finally
myConnection.close
End Try
End Sub
!--- function here
Function DisplayFormItem(ByVal strMFormControl, ByRef strMFormValue)
Select Case Trim(strMFormControl)
Case "textbox"
response.write ("<asp:TextBox runat=server id=" & strMFormValue &"
/></td></tr>" & Vbcrlf)
Case "checkbox"
End Select
End Function
</script>
I am trying to display some textboxes on my page, When I run the code the
textbox is written to the page (when I view source) but not to the screen.
Could someone tell me if I have the syntax correct?
Sean - thanks in advance for your answer
!-- code
response.write ("<asp:TextBox runat=server id=" & strMFormValue &"
/></td></tr>" & Vbcrlf)
<% @Import Namespace="System.Data" %>
<% @Import Namespace="System.Data.SqlClient" %>
<script language="vb" runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
If Not Page.IsPostBack then
BindData()
End If
End Sub
Sub BindData()
Dim dbRead As SqlDataReader
Dim strMFormControl as string
Dim strMFormValue as string
Dim strMDFormControl as string
Dim strMDFormValue as string
Dim myConnection as New
SqlConnection(ConfigurationSettings.AppSettings("connectionString"))
try
myConnection.Open()
Dim myCommand As New SqlCommand("GetFormById", myConnection)
myCommand.CommandType = CommandType.StoredProcedure
dbRead = myCommand.ExecuteReader()
While dbRead.Read ( )
strMFormValue = dbRead(1)
strMFormControl = dbRead(2)
strMDFormValue = dbRead(3)
strMDFormControl = dbRead(4)
response.write ("<form runat=server><table border=1 align=center>" &
Vbcrlf & _
"<tr><td colspan=2>" & dbRead(0) & "</td></tr>" & Vbcrlf & _
"<tr><td>" & strMFormValue & "</td><td>" & Vbcrlf)
DisplayFormItem(strMFormControl,strMFormValue)
response.write ("<tr><td>" & strMDFormValue & "</td><td>" & Vbcrlf)
DisplayFormItem(strMDFormControl,strMDFormValue)
response.write ("</table></form>")
End While
dbRead.close
Catch oexpData As OleDb.OleDbException
response.write ("an exception has occured,")
response.end
Finally
myConnection.close
End Try
End Sub
!--- function here
Function DisplayFormItem(ByVal strMFormControl, ByRef strMFormValue)
Select Case Trim(strMFormControl)
Case "textbox"
response.write ("<asp:TextBox runat=server id=" & strMFormValue &"
/></td></tr>" & Vbcrlf)
Case "checkbox"
End Select
End Function
</script>