从禁用内容页母版页的超链接 [英] Disable Hyperlink of Master page from content page
问题描述
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="AssociateMaster.master.cs" Inherits="EQ.AssociateMaster" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Employee Quotient</title>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
<link href="Styles/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script src="Scripts/jquery.alerts.js" type="text/javascript"></script>
<script src="Scripts/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="Scripts/jquery.js" type="text/javascript"></script>
<link href="Styles/jquery.alerts.css" rel="stylesheet" type="text/css" />
<meta name="Author" content="Dharmendra Kumar Singh" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<!--[if lt IE 7]>
<link rel="stylesheet" href="iefixes.css" type="text/css" />
<![endif]-->
</head>
<script type="text/jscript">
function clock(){
var d = new Date();
var h = d.getHours();
var m = d.getMinutes();
var s = d.getSeconds();
if (parseInt(h) < 10)
h = "0" + h;
if (parseInt(m) < 10)
m = "0" + m;
if (parseInt(s) < 10)
s = "0" + s;
$('#clock').html(", " + h + "<span class='colon'>:</span>" + m + "<span class='colon'>:</span>" + s);
// $('.colon').fadeTo(1000, .2);
setTimeout(clock, 1000);
}
</script>
<body onload="clock()">
<div id="container">
<div id="header">
<div id="logo">
<div id="Div1">
<h1 style="color:White;"> New EQ <%--<a href="../Associates/Home.aspx"><img style="width: 140px; height: 80px;" src="../images/eq.jpg" alt="" /></a>--%></h1>
</div>
</div>
<form id="search" method="get" action="">
<div>
<table>
<tr>
<td><asp:Label ID="lblUser" runat="server" Text="Label" Font-Bold="true" Font-Size="16px" ForeColor="White"></asp:Label></td>
<td><span class="line-separator"> </span></td>
<td>
<asp:HyperLink ID="SignOut" runat="server" style="color:White;font-size:15px;font-family:Calibri; background-color:transparent;font-weight: bold;" NavigateUrl="~/Account/EQLogin.aspx">Sign Out</asp:HyperLink></td>
</tr>
</table>
<table>
<tr>
<td >
<asp:Label ID="lblDate" runat="server" style="font-family:Calibri;color:White;font-weight:bold;font-size:1.3em;" />
<span id="clock" style="font-family:Calibri;color:White;font-weight:bold;font-size:1.3em;"></span>
</td>
</tr>
</table>
</div>
</form>
</div>
<div id="menu" >
<ul>
<li><a href="../Associates/Home.aspx">Home</a></li>
<li><a href="../Associates/Report.aspx">Report</a></li>
<li><a href="../Associates/MyProfile.aspx">Profile</a></li>
</ul>
</div>
<asp:ContentPlaceHolder ID="cphContent" runat="server" />
</div>
<div id="footer">
<div id="footer-left"></div>
<div id="footer-right"></div>
<div id="footer-content">
<div id="footer-navigation"> </div>
<p>Copyright © DKS All rights reserved.</p>
</div>
</div>
</body>
</html>
这是我的母版页的code和我想从内容页面。有一个场景,当我们正在迫使用户不受任何方式离开该页面内容禁止该母版页的所有超链接和出于这个原因,我想禁用该母版页的所有超链接。
请指导我,我如何禁用此。我不使用脚本管理,因为我已经申请脚本每个内容页面上管理和至今开发了这么多页所以不可能回滚和母版页上使用脚本管理器。
This is the code of my master page and i want to disable all the hyperlinks of this master page from the content page .There is a scenario when we are forcing user to not leave that content page from any ways and for that reason i want to disable all the hyperlinks of this master page. Please guide me that how i disable this. I am not using Script Manager as i had applied Script manage on every content page and till now developed so many pages so not possible to roll back and apply script manager on master page.
推荐答案
对不起没有看过你的答复关于做客户端...但对于服务器端:
Sorry didn't read your reply about doing it client side... but for server side:
您必须把在你的页面/用户控件标记为母版的参考。
You have to put a reference to the MasterPage in your page/user control markup.
<%@ Reference VirtualPath="..." %>
然后在code-的背后,你只投了Page.MasterPage你的母版,并访问其属性。
Then in the code-behind, you just cast the Page.MasterPage to your MasterPage and access its properties.
MyMasterPage myMasterPage = (MyMasterPage)Page.Master;
然后,您可以:
HyperLink myLink = (HyperLink)MyMasterPage.FindControl("nameOfLink");
myLink .Visible = false;
沿着这些线路的基础上,我所见过的东西,C#是有点生疏,但主要是存在的。
Something along those lines, based on what I've seen before, C# is a bit rusty but the principal is there.
这篇关于从禁用内容页母版页的超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!