Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从母版页的内容页添加控件_C#_Asp.net_Master Pages - Fatal编程技术网

C# 从母版页的内容页添加控件

C# 从母版页的内容页添加控件,c#,asp.net,master-pages,C#,Asp.net,Master Pages,我有一个母版页,看起来像这样: <table> <tr> <td> <asp:Label ID="lbl1" runat="server"></asp:Label> </td> <td> <asp:Label ID="lbl2" runat="server"></asp:Label> </td> </

我有一个母版页,看起来像这样:

<table>
<tr>
    <td>    
        <asp:Label ID="lbl1" runat="server"></asp:Label>
    </td>
    <td>
        <asp:Label ID="lbl2" runat="server"></asp:Label>
    </td>
</tr>
</table>

我在所有页面中都使用这种设计,除了一个页面,我想在第一个标签lbl1(两个标签位于同一行)之后添加一个按钮,然后在第二行上看到第二个标签。 我的问题是如何从内容页(最好是从代码隐藏)实现这一点?

创建默认为
Visible=false的
。在要查看该按钮的页面中,找到该按钮并使其
可见=true


当控件不可见时,它不呈现,这等于其他页面不存在

创建一个显示无的按钮。在特定的contant页面上,使用javascript查找按钮并更改其cssAt,这就是我所做的,但我不喜欢添加一个显示按钮:在一个100页的母版页上使用无,而该按钮仅在一页中使用检查我的答案,并告诉我是否有帮助。谢谢,我不知道,如果控件不可见,则表示不存在。我的意思是,我知道页面不会呈现它,但我只是发现,在这样做时,代码不是很明智so@next_user是的,您可以在浏览器中使用查看页面源代码进行检查。如果答案对你有帮助,你可以把它标记为正确。