如何覆盖asp.net中的母版页控件上的内容页面控件? [英] How to overwrite a content page control on a master page control in asp.net?

查看:81
本文介绍了如何覆盖asp.net中的母版页控件上的内容页面控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在母版页上有一个图像按钮,如下所示:

I have an image button on master page as follows:

<asp:ImageButton ID="ImageButton1"  ImageUrl="images/Refresh.png" ToolTip="Refresh Image List" runat="server" OnClick="Refrshbtn_Click" class="ipdbuttons" Visible="true">



我在内容上有另一个相同的图像按钮页面如下:


And i have another same image button on content page as follows:

<asp:ImageButton Visible="true" Style="width: 50px; font-size: x-large; max-width: 100px; text-align: left; margin-left: 385px; margin-top:9px;" ForeColor="#294b08" Height="95%" ImageUrl="images/Refresh.png" ToolTip="Refresh Image" runat="server" ID="ImageButton1" OnClick="Refrshbtn_Click">



我想用加载的主页图像按钮替换我的内容页面图像按钮。



请指导我...


I want to replace my content page image button with master page image button on load.

Please guide me...

推荐答案

在内容页面的页面加载事件中添加以下代码行



ImageButton imgBtn1 = Master.FindControl (ImageButton1)as ImageButton;

ImageButton1.Visible = false;

ImageButton1.Parent.Controls.Add(imgBtn1);
Add the below lines of code in page load event of content page

ImageButton imgBtn1 = Master.FindControl("ImageButton1") as ImageButton;
ImageButton1.Visible = false;
ImageButton1.Parent.Controls.Add(imgBtn1);


这篇关于如何覆盖asp.net中的母版页控件上的内容页面控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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