如何在asp.net中隐藏div [英] how to hide div in asp.net
本文介绍了如何在asp.net中隐藏div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在另一页上隐藏母版页div
how to hide master page div on another page
推荐答案
在母版页中添加id如下所示的div标签
Add the div tag with id as shown below in the master page
<div class=header id="id1" runat="server" >
<h1> can be hidden</h1>
现在在母版页的代码后面..你可以通过c#代码隐藏div标签
如图所示在下面的示例中
now in code behind of master page.. you can hide the div tag through c# code
as shown in sample below
public partial class SiteMaster : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
int x = new Random().Next(1, 3);
if (x == 1)
{
id1.Visible = true;
}
else
{
id1.Visible = false;
}
}
}
希望它会有所帮助你。
Hope it will help you.
< div style =visibility:hidden>< / div>
<div style="visibility:hidden"></div>
使用jquery或其他脚本。 ..
在contentplaceholder中编写脚本
并且可能masterdiv是你在母版页中的dic然后....
默认.aspx
use jquery or other script...
write your script in contentplaceholder
and might "masterdiv" is your dic in master page then....
default.aspx
<![CDATA[<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:content id="Content1" contentplaceholderid="head" runat="Server" xmlns:asp="#unknown">
<asp:content id="Content2" contentplaceholderid="ContentPlaceHolder1" runat="Server" xmlns:asp="#unknown">
<script type="text/javascript" src="Scripts/jquery-1.4.1.js"></script>
<script type="text/javascript">
这篇关于如何在asp.net中隐藏div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文