开发者

Anchor href attribute on Master.cs being overwritten

开发者 https://www.devze.com 2023-02-21 06:28 出处:网络
We have a Master page (asp.net) with a menu item (html anchor) which should not be populated with a href for a certain user role - but it\'s always showing!

We have a Master page (asp.net) with a menu item (html anchor) which should not be populated with a href for a certain user role - but it's always showing!

The Master.cs has:

<li><a id="manage" runat="server" href="~/Views/Manage.aspx" title="Manage details">Manage </a></li>

In the OnLoad event on the Master.cs we remove the HRef attribute if it's a certain user type - that seems to work OK, I've checked in the Watch window.

manage.Attributes.Remove(Constants.HREF_ATTRIBUTE);

The Watch windows confirms the HRef attribute being blanked out but开发者_开发问答 as soon as the Master.cs is displayed the HRef is back again, as if the HRef in the aspx has overwritten the 'removal' in the code.

Bear in mind this is my first post - I've tried to google it, to no avail. Any help greatly appreciated. Thanks, Pete


Since your anchor is a server side control you should use its Href property instead of removing an attribute:

manage.Href = string.Empty;


I fixed it - it's a weird fix! Can I just say, I'm bug fixing this system, I didn't write it!

A image was missing from the solution, so an error was occurring then being gobbled - causing a redirect to the error page which had the master.css applied to it.

Very strange and not one I'd expect anyone to get. Thanks for looking, Pete

0

精彩评论

暂无评论...
验证码 换一张
取 消