Solved

add property to asp.net page

Posted on 2009-04-02
2
241 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 250 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 250 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Angular JS Route 3 50
Receiving a string from a WebService Push 21 36
Pagebreak issue while printing the aspx page 3 15
C#.NET and microsoft certification. 3 32
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…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now