LoadControl and the PostBack problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jack

    LoadControl and the PostBack problem

    Hi folks,
    Consider a page consisting of a treeview, and a panel. The panel is
    supposed to be refreshed based on treeview node selection.

    protected void tree_SelectedNo deChanged(objec t sender, EventArgs e)
    {
    TreeNode node = this.tree.Selec tedNode;
    if (node != null)
    LoadMyControls( node);
    }

    Where LoadMyControls simply loads the associated control based on the
    node and adds it to the panel's controls collection. The loaded
    control, on the other side, is supposed to have a DropDownList
    control, which based on user selection updates a gridview. However,
    when a new item is selected in the combo box, the entire panel is
    vanished and a blank page appears.

    AFAIK, This indicates that the control has to be loaded again, hence,
    the LoadMyControls has to be invoked. So I added the following lines
    to the Page_Load function:

    Boolean isTreeThePostBa ckSource =
    this.scriptMana ger.AsyncPostBa ckSourceElement ID.Equals(this. tree.UniqueID);
    if (!isTreeThePost BackSource)
    {
    TreeNode node = this.tree.Selec tedNode;
    if (node != null)
    LoadMyControls( node);
    }

    This way, everything works fine.

    However, I've noticed that IsPostBack is always true, when the User
    Control gets loaded. So, I've got no mechanism to learn whether the
    user control should be initialized for the first time. How am I
    supposed to do this?

    Any help would be highly appreciated,

    Thanks
    Jack
  • Munna

    #2
    Re: LoadControl and the PostBack problem

    Hi,

    "However, I've noticed that IsPostBack is always true,"

    Page.IsPostback Is false when the page is requested for the first
    time...
    after each subsequent submit from any control the value is this
    variable is false

    regards

    Munna

    Comment

    • jack

      #3
      Re: LoadControl and the PostBack problem

      On Jul 28, 10:24 pm, Munna <munna...@gmail .comwrote:
      Hi,
      >
      "However, I've noticed that IsPostBack is always true,"
      >
      Page.IsPostback Is false when the page is requested for the first
      time...
      after each subsequent submit from any control the value is this
      variable is false
      >
      regards
      >
      Munna
      That's not the case when you use the LoadControl to load a user
      control dynamically!

      Comment

      Working...