Sivajith
Sivajith

Reputation: 1211

create label and put this control in href tag based on certain conditions

Can any one tell me how to create a label and put it in href tag using c# code. this is because, I need to use a single asp label control for both as label and link label.

So I want it to be programatically set based on certain parameter values. and this is ausercontro as well. Note: I cannot change the logic because this is client's requirement

regards, Sivajih S.

Upvotes: 0

Views: 460

Answers (1)

zey
zey

Reputation: 6103

Use asp:HyperLink control !

In your aspx ,

<asp:HyperLink ID="yourHyperLink" runat="server" >
</asp:HyperLink>

In your cs ,

if(....yourCondition...)
{
yourHyperLink.Text = "YourText";
yourHyperLink.NavigateUrl = "YourURL";
}

Upvotes: 2

Related Questions