i want to hide a save button in my master page?
i have a multiview having view1 and view2. view1 i have to save some details to my database and view2 i have a gridview. when loading view1 i want to show the save button in the masterpage.if loading view2 save开发者_C百科 button want to hide from master page
You can access the master page using Page.Master property. For example,
in master page code behind
public partial class MyMasterPage : System.Web.UI.MasterPage
{
public void ToggleSaveButton(bool visible)
{
SaveButton.Visible = visible
}
// other code
...
}
And in your page
((MyMasterPage)Master).ToggleSaveButton(true);
Button button = Master.FindControl("your button id") as Button;
button.Visible = true;
If you want to do it client side you can either use JQuery or Javascript because the master page control will also be rendered and hecnce you can easily find it using JQuery : $("#ControlId").css("display","none")
, Javascript : document.getElementById(...) and set its display to none.
精彩评论