HTML Hyperlink to Variable ASP.NET

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

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




Responses

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

Up
0
Down
Link.InnerHtml

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

Posted by: Bageshkumarbagi on: 12/12/2013 [Member] Starter | Points: 25

Up
0
Down
hi,

Refer this link:
http://websummaries.blogspot.in/2010/12/pass-and-use-variables-in-aspnet-server.html

Thanks,
Bagesh Kumar Singh
Mark as answer if you have been satisfied

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

Login to post response