问题描述
我已经编写了用于在内容页面的母版页面上启用和禁用超链接的代码.一切正常,并且在调用DisableHyperlinkInMasterPage方法后,超链接也被禁用.当我调用EnableHyperlinkInMasterPage方法时,超链接仍然无法正常工作.如果我们要离开该页面,那么我发现超链接开始工作.我的问题是在调用EnableHyperlinkInMasterPage方法之后,没有离开页面,超链接仍然被禁用并且不起作用,并且在离开页面后被启用.请帮助我解决此问题.我调试代码,但在EnableHyperlinkInMasterPage方法上未发现任何错误.
I had written code to Enable and disable hyperlinks on master page from the content page. Every thing is working fine and the hyperlinks are getting disabled also after calling the DisableHyperlinkInMasterPage Method. When i am calling the EnableHyperlinkInMasterPage method still the hyperlinks are not working. If we are leaving that page , then i found that the hyperlinks starts working. My issue is after calling the EnableHyperlinkInMasterPage method , without leaving the page the hyperlinks are still disabled and not working and after leaving the page it getting enabled . Please help me that how i fix this issue.I debug the code and not found any error on EnableHyperlinkInMasterPage method.
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;
}
推荐答案
private void DisableHyperlinkInMasterPage()
{
AssociateMaster mymaster = (AssociateMaster)Page.Master;
HyperLink home = (HyperLink)mymaster.FindControl("Home");
HyperLink profile = (HyperLink)mymaster.FindControl("ProfileLink");
HyperLink report = (HyperLink)mymaster.FindControl("Report");
HyperLink signout = (HyperLink)mymaster.FindControl("SignOut");
home.NavigateUrl= string.Empty;
profile.NavigateUrl= string.Empty;
report.NavigateUrl= string.Empty;
signout.NavigateUrl= string.Empty;
}
private void EnableHyperlinkInMasterPage()
{
AssociateMaster mymaster = (AssociateMaster)Page.Master;
HyperLink home = (HyperLink)mymaster.FindControl("Home");
HyperLink profile = (HyperLink)mymaster.FindControl("ProfileLink");
HyperLink report = (HyperLink)mymaster.FindControl("Report");
HyperLink signout = (HyperLink)mymaster.FindControl("SignOut");
home.NavigateUrl= "your_url";
profile.NavigateUrl= "your_url";
report.NavigateUrl= "your_url";
signout.NavigateUrl= "your_url";
}
有用.认证和经过测试! :)
希望对您有所帮助.
It works. Certified & Tested! :)
Hope it helps.
这篇关于不离开母版页就无法在母版页中启用超链接.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!