我编写了代码来从内容页面启用和禁用母版页上的超链接。一切正常,调用DisableHyperlinkInMasterPage
方法后超链接也被禁用。当我调用该EnableHyperlinkInMasterPage
方法时,超链接仍然不起作用。如果我们要离开该页面,那么我发现超链接开始工作。我的问题是在调用该EnableHyperlinkInMasterPage
方法后,在不离开页面的情况下,超链接仍然被禁用并且无法正常工作,并且在离开页面后它被启用。请帮助我解决这个问题。我调试代码并没有发现任何EnableHyperlinkInMasterPage
方法错误。
private void DisableHyperlinkInMasterPage()
{
AssociateMaster mymaster = (AssociateMaster)Page.Master;
HyperLink home = (HyperLink)mymaster.FindControl("Home");
home.Enabled = false;
HyperLink profile = (HyperLink)mymaster.FindControl("ProfileLink");
profile.Enabled = false;
HyperLink report = (HyperLink)mymaster.FindControl("Report");
report.Enabled = false;
HyperLink signout = (HyperLink)mymaster.FindControl("SignOut");
signout.Enabled = false;
}
private void EnableHyperlinkInMasterPage()
{
AssociateMaster mymaster = (AssociateMaster)Page.Master;
HyperLink home = (HyperLink)mymaster.FindControl("Home");
home.Enabled = true;
HyperLink profile = (HyperLink)mymaster.FindControl("ProfileLink");
profile.Enabled = true;
HyperLink report = (HyperLink)mymaster.FindControl("Report");
report.Enabled = true;
HyperLink signout = (HyperLink)mymaster.FindControl("SignOut");
signout.Enabled = true;
}