Link to home
Start Free TrialLog in
Avatar of sqlnoob
sqlnoob

asked on

C#, How do you put a hyperlink tag inside a control and still refer it in the code?

<asp:DetailsView>
<asp:HyperLink ID="lala" runat="server"></asp:HyperLink>
</asp:DetailsView>
lala.Text="hello"; // works


<EmptyDataTemplate><asp:HyperLink ID="lala" runat="server"></asp:HyperLink></EmptyDataTemplate>
lala.Text="hi"; // don't work, Error      100      The name 'lala' does not exist in the current context

already tried:
HyperLink _lala = (HyperLink)DetailsView1.FindControl("lala");
_lala.Text = "hello"

but it complies but the value is empty also when I try: _lala.NavigateUrl = "http://www.yahoo.com";
the url in the html is blank. I think it is only setting the copy's value not the original's value
ASKER CERTIFIED SOLUTION
Avatar of Obadiah Christopher
Obadiah Christopher
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sqlnoob
sqlnoob

ASKER

nope don't work :(


  protected void x_ItemCreated(object sender, DetailsViewPageEventArgs e)
  {
          HyperLink t1 = (HyperLink)x.FindControl("testlink");
          t1.Text = "yahoo";
          t1.NavigateUrl = "yahoo.com";

  }

<a id="ctl00_ContentPlaceHolder1_x_testlink">click me</a>
HyperLink _lala = (HyperLink)DetailsView1.Rows[DetailsView1.DataItemIndex].FindControl("lala");
            _lala.Text = "hello";
Avatar of sqlnoob

ASKER

hi informaniac,

it is not working :(
<asp:DetailsView>
<asp:HyperLink ID="lala" runat="server"></asp:HyperLink>
</asp:DetailsView>

Is this what u've written or is there something in between that you haven't posted.