启用/禁用母版页上的按钮 [英] enable/disable a button on master page

查看:87
本文介绍了启用/禁用母版页上的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个母版页和一个名为btnSave的通用保存按钮.
我有2个内容页面,分别是cp1,cp2.当我打开cp1时,将启用保存按钮.
当我打开cp2时,保存按钮被禁用..

如何从内容页面上启用/禁用母版页上的按钮?

I have a master page and a common save button named btnSave.
I have 2 content page say cp1, cp2. When i open cp1 then the save button is enable.
When i open cp2 the save button is disable..

How can i enable/disable a button on master page from content page?

推荐答案

您可以使用Page.Master.FindControl来访问母版页中的任何控件

例如访问名为"btnSave"的按钮,您可以使用

You can use Page.Master.FindControl to access any control in Master Page

for example to access button named "btnSave", You can Use

(Page.Master.FindControl("btnSave") as Button).Enabled = false;



就是这样.



Thats it.


cp1:
按钮Button1 =(Button)Master.FindControl("Button1");
Button1.Enabled = true;

cp2:
按钮Button1 =(Button)Master.FindControl("Button1");
Button1.Enabled = false;
cp1 :
Button Button1 = (Button)Master.FindControl("Button1");
Button1.Enabled = true;

cp2 :
Button Button1 = (Button)Master.FindControl("Button1");
Button1.Enabled = false;


这篇关于启用/禁用母版页上的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆