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:Hyper Link>
</asp:DetailsView>
lala.Text="hello"; // works
<EmptyDataTemplate><asp:Hy perLink ID="lala" runat="server"></asp:Hyper Link></Emp tyDataTemp late>
lala.Text="hi"; // don't work, Error 100 The name 'lala' does not exist in the current context
already tried:
HyperLink _lala = (HyperLink)DetailsView1.Fi ndControl( "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
<asp:HyperLink ID="lala" runat="server"></asp:Hyper
</asp:DetailsView>
lala.Text="hello"; // works
<EmptyDataTemplate><asp:Hy
lala.Text="hi"; // don't work, Error 100 The name 'lala' does not exist in the current context
already tried:
HyperLink _lala = (HyperLink)DetailsView1.Fi
_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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
HyperLink _lala = (HyperLink)DetailsView1.Ro ws[Details View1.Data ItemIndex] .FindContr ol("lala") ;
_lala.Text = "hello";
_lala.Text = "hello";
ASKER
hi informaniac,
it is not working :(
it is not working :(
<asp:DetailsView>
<asp:HyperLink ID="lala" runat="server"></asp:Hyper Link>
</asp:DetailsView>
Is this what u've written or is there something in between that you haven't posted.
<asp:HyperLink ID="lala" runat="server"></asp:Hyper
</asp:DetailsView>
Is this what u've written or is there something in between that you haven't posted.
ASKER
protected void x_ItemCreated(object sender, DetailsViewPageEventArgs e)
{
HyperLink t1 = (HyperLink)x.FindControl("
t1.Text = "yahoo";
t1.NavigateUrl = "yahoo.com";
}
<a id="ctl00_ContentPlaceHold