CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2003
    Posts
    107

    Unhappy Add hyperlink based on the user

    Hi,

    I have a very basic question. I have a single column datalist on my webpage which is a hyperlink and takes you to another page when clicked. I want to make this column a hyperlink based on the user permissions. So if the user has permission 'A' allow him to click on the link. Basically I want to make it a hyperlink if user has permission 'A' otherwise it should just be a simple text. Can anyone tell me how to do this.

    Thanks for your help.

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: Add hyperlink based on the user

    It should be a simple If-Then statement in the ASP code. If permission = 'A' then Response.Write the link. If not, Response.Write as text.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Nov 2003
    Posts
    107

    Unhappy Re: Add hyperlink based on the user

    Sorry I am really new to ASP .Net. I am not sure where I can add the if then statements. I am in the site.master page and here is what I have so far

    Code:
    <ItemTemplate>
               <asp:HyperLink ID="HyperLink1" runat="server"                     NavigateUrl="~/temp.aspx" 
                Text='<%# Eval("SummaryTxt") %>'  ></asp:HyperLink>
                </ItemTemplate>
    For this I want to check if user = "A" then
    Code:
             <asp:HyperLink ID="HyperLink1" runat="server"                     NavigateUrl="~/temp.aspx" 
                Text='<%# Eval("SummaryTxt") %>'  ></asp:HyperLink>
    else
    Code:
      <asp:Label ID="Label1" runat="server"
                                                         Text='<%# Eval("OutageSummaryTxt") %>'  ></asp:Label>
    Here are my questions.
    1. How do I declare the variable user.
    2. How do I start the if then clause.

    Thanks for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured