G
George
Hi
I'm trying to add a server control to a stringbuilder and I'd like
some suggestions please.
The output of the server control is 3 html combo boxes and I would
like to add the html output to the StringBuilder and then output
everyhting as HtmlTextWriter.
Thanks in Advance if you can help me.
Here are the lines of code where I want to add the control:
Protected Overrides Sub Render(ByVal output As
System.Web.UI.HtmlTextWriter)
Select Case _mode
Case RegLoginMode.Register
DisplayRegUI(output)
Case RegLoginMode.Login
DisplayLoginUI(output)
End Select
End Sub
Private Sub DisplayRegUI(ByVal Writer As HtmlTextWriter)
'Create StringBuilder for concatenating output string
Dim SBOut As New System.Text.StringBuilder
SBOut.Append(vbTab & "<table>" & vbCrLf)
SBOut.Append(vbTab & vbTab & "<tr>" & vbCrLf)
SBOut.Append(vbTab & vbTab & vbTab & "<td>" & vbCrLf)
SBOut.Append(vbTab & vbTab & vbTab & _
"Gender: " & vbCrLf)
SBOut.Append(vbTab & vbTab & vbTab & "</td>" & vbCrLf)
SBOut.Append(vbTab & vbTab & vbTab & "<td>" & vbCrLf)
SBOut.Append(vbTab & vbTab & vbTab & "<select name='" &
Me.UniqueID & "' id='" & _
Me.UniqueID & "'>" & vbCrLf)
SBOut.Append(vbTab & vbTab & vbTab & vbTab & "<option
value=""3"">Male</option>" & vbCrLf)
SBOut.Append(vbTab & vbTab & vbTab & vbTab & "<option
value=""4"">Female</option>" & vbCrLf)
SBOut.Append(vbTab & vbTab & vbTab & "</select>" & vbCrLf)
SBOut.Append(vbTab & vbTab & vbTab & "</td>" & vbCrLf)
SBOut.Append(vbTab & vbTab & "</tr>" & vbCrLf)
'Server control
Dim ActiveDateTime1 As New ActiveUp.WebControls.ActiveDateTime
ActiveDateTime1.MinYear = DateTime.Now.Year - 80
ActiveDateTime1.MaxYear = DateTime.Now.Year - 18
ActiveDateTime1.Format = "DAY;;MONTH;;YEAR;"
SBOut.Append(vbTab & vbTab & "<tr>" & vbCrLf)
SBOut.Append(vbTab & vbTab & vbTab & "<td>" & vbCrLf)
SBOut.Append(vbTab & vbTab & vbTab & _
"Date of Birth: " & vbCrLf)
SBOut.Append(vbTab & vbTab & vbTab & "</td>" & vbCrLf)
SBOut.Append(vbTab & vbTab & vbTab & "<td>" & vbCrLf)
'here is where I want to add the server control html output but it's
obvious that it doesn't work
SBOut.Append(vbTab & vbTab & vbTab &
Controls.Add(ActiveDateTime1) & vbCrLf)
SBOut.Append(vbTab & vbTab & vbTab & "</td>" & vbCrLf)
SBOut.Append(vbTab & vbTab & "</tr>" & vbCrLf)
'Send the output to the browser.
Writer.Write(SBOut)
End Sub
I'm trying to add a server control to a stringbuilder and I'd like
some suggestions please.
The output of the server control is 3 html combo boxes and I would
like to add the html output to the StringBuilder and then output
everyhting as HtmlTextWriter.
Thanks in Advance if you can help me.
Here are the lines of code where I want to add the control:
Protected Overrides Sub Render(ByVal output As
System.Web.UI.HtmlTextWriter)
Select Case _mode
Case RegLoginMode.Register
DisplayRegUI(output)
Case RegLoginMode.Login
DisplayLoginUI(output)
End Select
End Sub
Private Sub DisplayRegUI(ByVal Writer As HtmlTextWriter)
'Create StringBuilder for concatenating output string
Dim SBOut As New System.Text.StringBuilder
SBOut.Append(vbTab & "<table>" & vbCrLf)
SBOut.Append(vbTab & vbTab & "<tr>" & vbCrLf)
SBOut.Append(vbTab & vbTab & vbTab & "<td>" & vbCrLf)
SBOut.Append(vbTab & vbTab & vbTab & _
"Gender: " & vbCrLf)
SBOut.Append(vbTab & vbTab & vbTab & "</td>" & vbCrLf)
SBOut.Append(vbTab & vbTab & vbTab & "<td>" & vbCrLf)
SBOut.Append(vbTab & vbTab & vbTab & "<select name='" &
Me.UniqueID & "' id='" & _
Me.UniqueID & "'>" & vbCrLf)
SBOut.Append(vbTab & vbTab & vbTab & vbTab & "<option
value=""3"">Male</option>" & vbCrLf)
SBOut.Append(vbTab & vbTab & vbTab & vbTab & "<option
value=""4"">Female</option>" & vbCrLf)
SBOut.Append(vbTab & vbTab & vbTab & "</select>" & vbCrLf)
SBOut.Append(vbTab & vbTab & vbTab & "</td>" & vbCrLf)
SBOut.Append(vbTab & vbTab & "</tr>" & vbCrLf)
'Server control
Dim ActiveDateTime1 As New ActiveUp.WebControls.ActiveDateTime
ActiveDateTime1.MinYear = DateTime.Now.Year - 80
ActiveDateTime1.MaxYear = DateTime.Now.Year - 18
ActiveDateTime1.Format = "DAY;;MONTH;;YEAR;"
SBOut.Append(vbTab & vbTab & "<tr>" & vbCrLf)
SBOut.Append(vbTab & vbTab & vbTab & "<td>" & vbCrLf)
SBOut.Append(vbTab & vbTab & vbTab & _
"Date of Birth: " & vbCrLf)
SBOut.Append(vbTab & vbTab & vbTab & "</td>" & vbCrLf)
SBOut.Append(vbTab & vbTab & vbTab & "<td>" & vbCrLf)
'here is where I want to add the server control html output but it's
obvious that it doesn't work
SBOut.Append(vbTab & vbTab & vbTab &
Controls.Add(ActiveDateTime1) & vbCrLf)
SBOut.Append(vbTab & vbTab & vbTab & "</td>" & vbCrLf)
SBOut.Append(vbTab & vbTab & "</tr>" & vbCrLf)
'Send the output to the browser.
Writer.Write(SBOut)
End Sub