Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

add property to asp.net page

Posted on 2009-04-02
2
Medium Priority
?
249 Views
Last Modified: 2012-05-06
I have asp.net app using master page

I need to have a hyperlink that is displayed on page if a user is in a certain role.
I need an elegant solution to this, I am using   .net 3.5
0
Comment
Question by:mugsey
2 Comments
 
LVL 14

Accepted Solution

by:
Dustin Hopkins earned 1000 total points
ID: 24050257
I'm not sure of an elegant solution, but you could place a button and set visible to false. Then in the page_load() of the code behind detect if the user is in the correct role and set visible to true.

The code below is for a linkbutton, but it should work with any control.

Hope this helps,
Dustin
 <asp:LinkButton ID="lbdelbtn" runat="server" CausesValidation="False" PostBackUrl="deleterec.aspx" Visible="False">Delete Record</asp:LinkButton>
 
 
If User.IsInRole("Admins") Then
            lbdelbtn.Visible = True
        End If

Open in new window

0
 
LVL 23

Assisted Solution

by:apresto
apresto earned 1000 total points
ID: 24050258
Why dont you create the control
<asp:Hyperlink runat="server" visible="false"
and change the visible property based on the users role in the codebehind.
Either that, or you could create the hyperlink on the fly and add it to a placeholder or tablecell
HyperLink link = new HyperLink();
link.NavigationURl = "???";
etc
Yourcontainer.Controls.Add(link);
If you choose this method i would suggest you have it in your Page_Init event rather than the page_load
 
 
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

877 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question