add server control to stringbuilder

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: George (george_Martinho_at_hotmail.com)
Date: 03/09/04


Date: 9 Mar 2004 07:17:52 -0800

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



Relevant Pages

  • Re: Design flow for Code-behind
    ... Some are simply Controls that render their own HTML. ... Not complicated for a good HTML designer. ... The Server Control also has a CSS class. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Postback on a button query
    ... I'm not sure I'm 100% of what you're saying, ... just want an HTML button, not a Server Control button. ... > of all the dynamic stuff, and therfore clearing all the text boxes that ...
    (microsoft.public.dotnet.framework.aspnet)
  • why is this statement preventing an event handler to be called on the server
    ... I have a html control of type submit which has runat=server making it a html ... I have an event handler on the client and on the server for the same html ... server control as you can see below. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Design flow for Code-behind
    ... Each Server Control renders a Div or a Table, ... The Server Control also has a CSS class. ... Our designer can then work on an external CSS style sheet to provide the ... HTML element IN the Server Control will be rendered on the client, ...
    (microsoft.public.dotnet.framework.aspnet)
  • add server control to stringbuilder
    ... I'm trying to add a server control to a stringbuilder and I'd like ... The output of the server control is 3 html combo boxes and I would ...
    (microsoft.public.dotnet.framework.aspnet.buildingcontrols)