Solved

add property to asp.net page

Posted on 2009-04-02
2
245 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

623 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