当其他页面使用时,我如何隐藏SiteMaste中的潜水 [英] how i can hide a dive in sitemaste when other page using

查看:60
本文介绍了当其他页面使用时,我如何隐藏SiteMaste中的潜水的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨亲爱的,
我在sitemaster中写了一个div html代码,
然后,我使用sitemaster(frmTest.aspx)添加表单,
frmtest有一个按钮(btnTest),
我想当我单击btnTest时,站点管理员的潜水隐藏
谢谢.

hi dear''s,
i wrote a div html code in sitemaster,
then,i add a form using sitemaster(frmTest.aspx),
frmtest have a button(btnTest),
i want when i click on the btnTest,the dive on the sitemaster hide,
thank''s.

推荐答案

如果您的div和按钮是服务器端标签,请在按钮上使用此按钮单击
if your div and button is server side tags use this on your buttons click
protected void btnTest_Click(object sender, EventArgs e)
{
 HtmlContainerControl div= (HtmlContainerControl)this.Master.FindControl("your_div_in_maste_page");
  div.Visible = false;
}


我为您提供了切换div的示例,但您只能将这种方法用于show/hide.

例如,您在MasterPage中有一个Div,如下所示:
I am providing you and example for toggling your div but you can use this approach for only show/hide.

For example you have a Div within MasterPage like the following:
<div id="myDivBox" style="display:none; width :300px">
          For hiding and showing your div dynamically via JavaScript. This content will toggle.
        </div>


而且您在子页面中有一个继承该MasterPage的按钮:


And you have a Button within Child Page which inherits that MasterPage:

<asp:button id="button1" runat="server" onclick="toggleDiv()" />


现在,在ContentPlaceHolder中编写以下脚本:


Now write the following scripts within ContentPlaceHolder:

<script language="javascript" type="text/javascript">
       function toggleDiv()
       {
         if (document.getElementById("myDivBox").style.display == "block")
         {
           document.getElementById("myDivBox").style.display = "none";
         }
         else
         {
           document.getElementById("myDivBox").style.display = "block";
         }
       }
     </script>



有关更多详细信息,请浏览以下链接:

在按钮单击时显示隐藏div,而无需回发
如何隐藏,显示或切换您的div

您将在Google上找到更多示例.



For further detail please navigate the following links:

Show hide div on button click without postback
How to hide, show, or toggle your div

You will find more examples on Google.


这篇关于当其他页面使用时,我如何隐藏SiteMaste中的潜水的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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