Click here to Skip to main content
15,907,493 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,



In my aspx page i wrote code as :

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <asp:Label ID="lblQues" runat="server" /></br>
    <asp:Button ID="btnAns" runat="server" Text="Answer" OnClick="btnAns_Click" /></br>
    <asp:Label ID="lblAns" runat="server" />
</asp:Content>



on page load i write the code as: ( i binded my anchor tag with in label)
lblQues.Text = String.Concat("What is my <a name ='test' id='lnkMe'  runat="server" href='#' >anchor</a> name?");



My question is how to get is of the anchor id as output that should display in my "lblAns" Label as output.

thanks,
Sindhu.
Posted
Comments
Naga Sindhura 10-Feb-14 8:27am    
Hi SambasivaRaoG,
I need to implement this code Using Labels and my output is id of the anchor tag.
Siva Hyderabad 10-Feb-14 8:44am    
Try this
Label1.Text = @what is my"anchorname";
Naga Sindhura 10-Feb-14 9:50am    
Hi SambasivaRaoG,
I am not able to get the id of my anchor tag.
Naga Sindhura 10-Feb-14 9:53am    
Hi SambasivaRaoG,
In my problem i need to get id of anchor tag. No need to assign assign any thing.
from the first label i need to get id and that id should display second label on button click. Please help me for this.
Siva Hyderabad 11-Feb-14 1:42am    
hi..your solution is solved or not?

XML
<%@ Page Language="C#" %>

<!DOCTYPE html>

<script runat="server">

    protected void anchor1_ServerClick(object sender, EventArgs e)
    {
        anci.InnerHtml = " welcome to anchor tag";
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <a id="anchor1" runat ="server" onserverclick ="anchor1_ServerClick">Click here</a>
        <br />
        <span id="anci" runat ="server" ></span>
    </div>
    </form>
</body>
</html>


or

C#
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

String BeginLink = "http://www.mysite.com/uploads/";
String RadUploadedFile = this.RadUpload1.UploadedFiles[0].FileName;

Label1.Text = @"<a href=""" + BeginLink + RadUploadedFile + @""">Download</a>";






Try this
XML
Try this
Label1.Text = @what is my "<a name  ='test' id='lnkMe'   runat="server" href='#'anchor</a>name";
 
Share this answer
 
v5
use
ASP.NET
<asp:literal id="lblQues" runat="server"></asp:literal>

instead of
ASP.NET
<asp:label id="lblQues" runat="server" />

and use this one on .cs page..
C#
lblQues.Text = "What is my <a name=\"test\" id=\"lnkMe\" href=\"#\">anchor</a> name?";
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900