Asp.net Hyperlink control equivalent to

前端 未结 6 1220
眼角桃花
眼角桃花 2021-02-06 23:35

I wanted to define a HyperLink control in asp.net that produces html output similar to the following:


but can\

相关标签:
6条回答
  • 2021-02-07 00:17

    If you want to add the value on aspx page , Just enter <a href='your link'>clickhere</a>

    If you are trying to achieve it via Code-Behind., Make use of the Hyperlink control

    HyperLink hl1 = new HyperLink();
    hl1.text="Click Here";
    hl1.NavigateUrl="http://www.stackoverflow.com";
    
    0 讨论(0)
  • 2021-02-07 00:19

    Asp:Hyperlink http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.hyperlink.aspx

    0 讨论(0)
  • 2021-02-07 00:24

    I agree with SLaks, but here you go

       <asp:HyperLink id="hyperlink1" 
                      NavigateUrl="#"
                      Text=""
                      runat="server"/> 
    

    or you can alter the href using

    hyperlink1.NavigateUrl = "#"; 
    hyperlink1.Text = string.empty;
    
    0 讨论(0)
  • 2021-02-07 00:34
    hyperlink1.NavigateUrl = "#"; or
    hyperlink1.attributes["href"] = "#"; or
    <asp:HyperLink NavigateUrl="#" runat="server" />
    
    0 讨论(0)
  • 2021-02-07 00:41

    Just write <a href="#"></a>.

    If that's what you want, you don't need a server-side control.

    0 讨论(0)
  • 2021-02-07 00:41

    If you need to access this as a server-side control (e.g. you want to add data attributes to a link, as I did), then there is a way to do what you want; however, you don't use the Hyperlink or HtmlAnchor controls to do it. Create a literal control and then add in "Your Text" as the text for the literal control (or whatever else you need to do that way). It's hacky, but it works.

    0 讨论(0)
提交回复
热议问题