Add a Webcombo inside PlaceHolder, when try to input, invoke Page_Load twice

5 replies. Last post: December 23, 2010 9:48 AM by Handy Surya
Tags :
  • New Discussion
  • New Question
  • New Product Feedback
Fung InterMember

Dear Sir/ Madam,

  I added a dynamically generated webcombo inside a place holder, bind it to a datasource, when I try to input value into the webcombo, the page will reload twice (one is post back, another one is not postback (flypostback?) and I can't input any value to the webcombo (since the page is reload)

Please kindly help to investigate the issue. Thanks.

 

Regards,

Fung

 

here is the code:

aspx page:

<body runat="server" style="width: 100%; height: 100%; overflow:hidden">
    <form id="form1" runat="server">
    <div>
        <asp:PlaceHolder ID="PlaceHolder1" runat="server" ViewStateMode="Enabled">
        </asp:PlaceHolder>
        <br />
    </div>
    
    </form>
</body>

vb Code:

Public Class webCombo
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Not IsPostBack Then
            PlaceHolder1.Controls.Add(createCBO)
        End If
    End Sub

    Private Function GetData2() As DataTable
        Dim dt As New DataTable
        With dt.Columns
            .Add("Text")
            .Add("Value")
            .Add("Display")
        End With
        For i As Integer = 1 To 250
            With dt.Rows
                .Add(i & i, i, i)
            End With
        Next
        Return dt
    End Function

    Private Function createCBO() As ISNet.WebUI.WebCombo.WebCombo
        Dim cboWebCombo As New ISNet.WebUI.WebCombo.WebCombo
        Dim dt As New DataTable
        Dim sbBindText As New System.Text.StringBuilder

        dt = GetData2()

        With cboWebCombo
            .ID = "cbo"
            .DataValueField = dt.Columns(0).ColumnName
            .DataTextField = dt.Columns(1).ColumnName
            .DataSource = dt
            .DataBind()

            .UseDefaultStyle = True
            .Enabled = True
            .Latency = 250
            .AllowAutoPostback = False
        End With

        Return cboWebCombo

    End Function

End Class

 

All times are GMT -5. The time now is 2:03 AM.
Previous Next