Enable and Disable button in Master Page if Conditon Fulfilled

hey fiends,

       I am having a MasterPage in my project..In my MasterPage there is Button Panel with Five Buttons in it, A TreeView for navigating across Pages and DropDownList for filtering Process.

      My requirement is that when my Home Pge gets Loaded at that time all the above Controls mentioned should be visible but not Enabled except the TreeView Control..

      Later when i Select One of the TreeViewNode(Which vil redirect me to the child page. ex LDC  is my  TreeNode), then at that time My buttons in the buttons panel and my Dropdown shall be Enabled..

Thanks,

Sushant2014

Disable the panel from html markup and enable the same on selection of treeview node.

hey can you list down the code at selection of treeview node…

eg. if i selected node by default is Home, in which i want my button panel to be disabled

but when i click on my second treeview node which is "LDC" i want that Button Panel to be enabled

protected void TreeView2_SelectedNodeChanged(object sender, EventArgs e)
{
    if (TreeView2.SelectedNode.Text == "LDC")
    {
        Panel1.Visible=false;
    }
    else if (...)
    else
    {
       // BLAH BLAH ...
    }
}

Hey i did the Same Code but it is not working…

what is the error you are facing ??? did you saw i edited code.?

if (tree_Menu.SelectedValue == "Data Mapping")
{
Panel2.Enabled = false;

}

if (tree_Menu.SelectedValue == "LDC")
{
Panel2.Enabled = true;

}

if (tree_Menu.SelectedValue == "CAMP")
{
Panel2.Enabled = true;

}

if (tree_Menu.SelectedValue == "MDTE")
{
Panel2.Enabled = true;

}

if (tree_Menu.SelectedValue == " LDC")
{
Panel2.Enabled = true;

}

if (tree_Menu.SelectedValue == " CAMP")
{
Panel2.Enabled = true;

}

if (tree_Menu.SelectedValue == " MDTE")
{
Panel2.Enabled = true;

}

This is my Code for Different Nodes

use selectednode.text … 

if (tree_Menu.SelectedNode.Text == "Data Mapping")
{
  ...
}
..
..
..
..

put a breakpoint and see what your are getting in tree_Menu.SelectedNode.Text

it is showing empty..

show your treeview markup …

i have use Site Map Data source for navigation purpose..

below is my treeview markup

<asp:TreeView ID="tree_Menu" runat="server" DataSourceID="SiteMapDataSource1"
ImageSet="Arrows" onselectednodechanged="tree_Menu_SelectedNodeChanged"
BackColor="#FFFF99" ForeColor="Black" style="color: #99FFCC">
<HoverNodeStyle Font-Underline="True" ForeColor="#5555DD" BackColor="#FF9933"
BorderStyle="None" />
<LeafNodeStyle ForeColor="Black" />
<NodeStyle Font-Names="Tahoma" Font-Size="10pt" ForeColor="Black"
HorizontalPadding="5px" NodeSpacing="0px" VerticalPadding="0px" />
<ParentNodeStyle Font-Bold="False" />
<SelectedNodeStyle Font-Underline="True" ForeColor="#5555DD"
HorizontalPadding="0px" VerticalPadding="0px" />
</asp:TreeView>

nd web.sitemap file

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode title="Data Mapping" url="Home.aspx" >
<siteMapNode title="Center Region Mapping">
<siteMapNode title="LDC" url ="LDC.aspx" />
<siteMapNode title="CAMP" url ="CAMP.aspx" />
<siteMapNode title="MDTE" url ="MDTE.aspx" />
</siteMapNode>
<siteMapNode title="Manager Region Mapping">
<siteMapNode title=" LDC" url ="LDC1.aspx" />
<siteMapNode title=" CAMP" url ="CAMP1.aspx" />
<siteMapNode title=" MDTE" url ="MDTE1.aspx" />
</siteMapNode>
<siteMapNode title="Reports">
<siteMapNode title ="HR" url="HR.aspx" />
<siteMapNode title ="Operation" url ="Operation.aspx" />
<siteMapNode title ="Student" url ="Student.aspx" />
</siteMapNode>
</siteMapNode>
</siteMap>

hey guys lend me some solution out of this…m not getting the solution what i wanted..

thanks sushant2014

Leave a Reply