HTML Hyperlink to Variable ASP.NET

Posted by Write2varun under C# on 12/11/2013 | Points: 10 | Views : 903 | Status : [Member] | Replies : 1

I Have a HTML Hyperlink in a Datagrid

I want to Assign the URL from that Hyperlink to a a variable

this is what i have done so far

aspx page

<asp:TemplateColumn> <ItemTemplate>
<a id="Link" href="java<!-- no -->script:OpenAttachment('<%# DataBinder.Eval(Container, "DataItem.Link")%>');">
<%# DataBinder.Eval(Container, "DataItem.Link")%></a>
</ItemTemplate> </asp:TemplateColumn>

in .cs page

HtmlGenericControl Link = (HtmlGenericControl)lDgModel.FindControl("Link");

string Link1 = Link. ?? .ToString();

what i have to enter in place of "??" to assign the URL to the variable

thank you


Posted by: vishalneeraj-24503 on: 12/11/2013 [Member] [MVP] Platinum | Points: 25


Use InnerHtml property to get value from htmlgeneric control

//Now write

string Link1 = (!string.IsNullOrEmpty(Link.InnerHtml)) ? Link.InnerHtml : string.Empty;

if Link.Innerhtml has some value then it returns value otherwise empty.

Write2varun, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response