J
jack
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_SelectedNodeChanged(object sender, EventArgs e)
{
TreeNode node = this.tree.SelectedNode;
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 isTreeThePostBackSource =
this.scriptManager.AsyncPostBackSourceElementID.Equals(this.tree.UniqueID);
if (!isTreeThePostBackSource)
{
TreeNode node = this.tree.SelectedNode;
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
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_SelectedNodeChanged(object sender, EventArgs e)
{
TreeNode node = this.tree.SelectedNode;
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 isTreeThePostBackSource =
this.scriptManager.AsyncPostBackSourceElementID.Equals(this.tree.UniqueID);
if (!isTreeThePostBackSource)
{
TreeNode node = this.tree.SelectedNode;
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