﻿<?xml version="1.0" encoding="utf-8"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Intersoft Community - WebCombo - Add a Webcombo inside PlaceHolder, when try to input, invoke Page_Load twice</title><link>http://www.intersoftsolutions.com/Community/WebCombo/Add-a-Webcombo-inside-PlaceHolder-when-try-to-input-invoke-PageLoad-twice/</link><description /><generator>http://www.intersoftsolutions.com</generator><language>en</language><copyright>Copyright 2002 - 2015 Intersoft Solutions Corp. All rights reserved.</copyright><ttl>60</ttl><item><title>Add a Webcombo inside PlaceHolder, when try to input, invoke Page_Load twice</title><link>http://www.intersoftsolutions.com/Community/WebCombo/Add-a-Webcombo-inside-PlaceHolder-when-try-to-input-invoke-PageLoad-twice/</link><pubDate>Thu, 23 Dec 2010 09:48:07 GMT</pubDate><dc:creator>handy@intersoftpt.com</dc:creator><category>WebCombo</category><category>placeholder</category><description>&lt;p&gt;Hello Fung,&lt;/p&gt;&lt;p&gt;I did not understand about "it won't be able to retieve data". Shouldn't when you type in WebCombo pr show the dropdown, it will trigger &lt;b&gt;IntializeDataSource &lt;/b&gt;event?&lt;/p&gt;
&lt;p&gt;Unfortunately, you could not place Not &lt;b&gt;IsPostBack &lt;/b&gt;condition, because WebCombo must be always created. Otherwise, it's gone.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Handy&lt;/p&gt;</description></item><item><title>Add a Webcombo inside PlaceHolder, when try to input, invoke Page_Load twice</title><link>http://www.intersoftsolutions.com/Community/WebCombo/Add-a-Webcombo-inside-PlaceHolder-when-try-to-input-invoke-PageLoad-twice/</link><pubDate>Wed, 22 Dec 2010 21:48:32 GMT</pubDate><dc:creator>interfung</dc:creator><category>WebCombo</category><category>placeholder</category><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;  Thanks, your sample is working. Since I need to generate a lot of webcom in one page and it increase the page's loading time if I go through the whole page load each time flypostback. &lt;/p&gt;
&lt;p&gt;to describe in code would be:&lt;/p&gt;&lt;pre&gt;    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

&lt;/pre&gt;

&lt;p&gt;but when I do this to the sample you provided, the webcombo would not be able to retreive data. Is there any work around for this case?&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Thanks and Regards,&lt;/p&gt;
&lt;p&gt;Fung&lt;/p&gt;</description></item><item><title>Add a Webcombo inside PlaceHolder, when try to input, invoke Page_Load twice</title><link>http://www.intersoftsolutions.com/Community/WebCombo/Add-a-Webcombo-inside-PlaceHolder-when-try-to-input-invoke-PageLoad-twice/</link><pubDate>Wed, 22 Dec 2010 15:51:47 GMT</pubDate><dc:creator>handy@intersoftpt.com</dc:creator><category>WebCombo</category><category>placeholder</category><description>&lt;p&gt;Hello,&lt;/p&gt;&lt;p&gt;Which one is not working? The fullpostback should be not persisted anymore. Please see my attached sample.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Handy&lt;/p&gt;</description></item><item><title>Add a Webcombo inside PlaceHolder, when try to input, invoke Page_Load twice</title><link>http://www.intersoftsolutions.com/Community/WebCombo/Add-a-Webcombo-inside-PlaceHolder-when-try-to-input-invoke-PageLoad-twice/</link><pubDate>Tue, 21 Dec 2010 20:35:00 GMT</pubDate><dc:creator>interfung</dc:creator><category>WebCombo</category><category>placeholder</category><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;  Thanks Handy for providing a better approach. I have tried the suggestion. But the problem still persist, please kindly help.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Thanks again,&lt;/p&gt;
&lt;p&gt;Fung&lt;/p&gt;</description></item><item><title>Add a Webcombo inside PlaceHolder, when try to input, invoke Page_Load twice</title><link>http://www.intersoftsolutions.com/Community/WebCombo/Add-a-Webcombo-inside-PlaceHolder-when-try-to-input-invoke-PageLoad-twice/</link><pubDate>Tue, 21 Dec 2010 15:23:24 GMT</pubDate><dc:creator>handy@intersoftpt.com</dc:creator><category>WebCombo</category><category>placeholder</category><description>&lt;p&gt;Hello,&lt;/p&gt;&lt;p&gt;Based On my investigation, this is not cause by PlaceHolder. Event a small div can also replicate your issue. Some of your approaches is not correct and not postback condition in Page_Load also cause this issue. &lt;/p&gt;
&lt;p&gt;Please see my approaches in below. Hope this helps.&lt;/p&gt;
&lt;p /&gt;&lt;pre&gt;Imports System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports ISNet.WebUI.WebCombo
&lt;span style="color: rgb(63, 63, 63); font-family: 'segoe ui', arial, verdana, tahoma; white-space: normal; line-height: 18px; "&gt;&lt;pre style="font-family: 'courier new', tahoma; background-color: rgb(255, 252, 225); font-size: 9pt; white-space: pre-wrap; word-wrap: break-word; "&gt;Public Class webCombo
    Inherits System.Web.UI.Page&lt;/pre&gt;&lt;/span&gt;    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        PlaceHolder1.Controls.Add(createCBO)
    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 &amp;amp; i, i, i)
            End With
        Next
        Return dt
    End Function
    Private Function createCBO() As WebCombo
        Dim cboWebCombo As New WebCombo
        Dim dt As New DataTable
        Dim sbBindText As New System.Text.StringBuilder
        AddHandler cboWebCombo.InitializeDataSource, AddressOf cboWebCombo_InitializeDataSource
        With cboWebCombo
            .ID = "cbo"
            .UseDefaultStyle = True
            .Enabled = True
            .Latency = 250
            .AllowAutoPostback = False
        End With
        Return cboWebCombo
    End Function
    Protected Sub cboWebCombo_InitializeDataSource(ByVal sender As Object, ByVal e As ISNet.WebUI.WebCombo.DataSourceEventArgs)
        Dim cboWebCombo As WebCombo = CType(sender, WebCombo)
        e.DataSource = GetData2()
        cboWebCombo.DataValueField = "Text"
        cboWebCombo.DataTextField = "Value"
    End Sub
End Class
&lt;/pre&gt;
&lt;p&gt;Regards,&lt;br /&gt;Handy&lt;/p&gt;
&lt;p /&gt;</description></item><item><title>Add a Webcombo inside PlaceHolder, when try to input, invoke Page_Load twice</title><link>http://www.intersoftsolutions.com/Community/WebCombo/Add-a-Webcombo-inside-PlaceHolder-when-try-to-input-invoke-PageLoad-twice/</link><pubDate>Tue, 21 Dec 2010 06:07:23 GMT</pubDate><dc:creator>interfung</dc:creator><category>WebCombo</category><category>placeholder</category><description>&lt;p&gt;Dear Sir/ Madam,&lt;/p&gt;
&lt;p&gt;  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)&lt;/p&gt;
&lt;p&gt;Please kindly help to investigate the issue. Thanks.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Fung&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;here is the code:&lt;/p&gt;
&lt;p&gt;aspx page:&lt;/p&gt;&lt;pre&gt;&amp;lt;body runat="server" style="width: 100%; height: 100%; overflow:hidden"&amp;gt;
    &amp;lt;form id="form1" runat="server"&amp;gt;
    &amp;lt;div&amp;gt;
        &amp;lt;asp:PlaceHolder ID="PlaceHolder1" runat="server" ViewStateMode="Enabled"&amp;gt;
        &amp;lt;/asp:PlaceHolder&amp;gt;
        &amp;lt;br /&amp;gt;
    &amp;lt;/div&amp;gt;
    
    &amp;lt;/form&amp;gt;
&amp;lt;/body&amp;gt;&lt;/pre&gt;
&lt;p&gt;vb Code:&lt;/p&gt;&lt;pre&gt;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 &amp;amp; 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&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;</description></item></channel></rss>