J
joseph
Hi,
I have created 2 custom user controls, one is gridview search list and the
other is login control. I use a webform, which has a treeview menu one side,
to load one of the user control when user click each one of the treeview
node. The treeview has 2 nodes, one is 'Search List', another is 'Login'. I
can load the user control on the treeview's SelectedNodeChanged event, but
there is the weird thing. When I click on the Login node, it shows the Login
Control, but when I click on the submit button, the login control will
disappear. This happen to the gridview control too. Another way is if I
clink on the same node the second time, the user control will disappear.
Below is my code:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
LoadUserControl();
}
}
protected void TreeView1_SelectedNodeChanged(object sender,
EventArgs e)
{
TreeView tv = (TreeView)sender;
Session["TreeNode"] = tv.SelectedNode.Text.ToLower();
LoadUserControl();
}
protected void LoadUserControl()
{
PanelSearchList.Controls.Clear();
Control SearchListControl = null;
switch (Session["TreeNode"].ToString().ToLower().Trim())
{
case "login":
SearchListControl = LoadControl("LoginUserControl.ascx");
break;
default:
SearchListControl = LoadControl("SearchControl.ascx");
break;
}
PanelSearchList.Controls.Add(SearchListControl);
}
Can anyone tell me how to solve this problem?
Thanks in advance.
Joseph
I have created 2 custom user controls, one is gridview search list and the
other is login control. I use a webform, which has a treeview menu one side,
to load one of the user control when user click each one of the treeview
node. The treeview has 2 nodes, one is 'Search List', another is 'Login'. I
can load the user control on the treeview's SelectedNodeChanged event, but
there is the weird thing. When I click on the Login node, it shows the Login
Control, but when I click on the submit button, the login control will
disappear. This happen to the gridview control too. Another way is if I
clink on the same node the second time, the user control will disappear.
Below is my code:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
LoadUserControl();
}
}
protected void TreeView1_SelectedNodeChanged(object sender,
EventArgs e)
{
TreeView tv = (TreeView)sender;
Session["TreeNode"] = tv.SelectedNode.Text.ToLower();
LoadUserControl();
}
protected void LoadUserControl()
{
PanelSearchList.Controls.Clear();
Control SearchListControl = null;
switch (Session["TreeNode"].ToString().ToLower().Trim())
{
case "login":
SearchListControl = LoadControl("LoginUserControl.ascx");
break;
default:
SearchListControl = LoadControl("SearchControl.ascx");
break;
}
PanelSearchList.Controls.Add(SearchListControl);
}
Can anyone tell me how to solve this problem?
Thanks in advance.
Joseph