Alina Anjum Alina Anjum - 5 months ago 8x
Javascript Question

How to get anchor text in a Session variable?

I am working on a project in which i have linked many pdf files in the master page.On clicking the anchor the page redirected to the specified page and displays pdf in iframe.Now i want the text in anchor tag to be displayed on the page where pdf is opened.
Consider I have an anchor which looks like this :

<a href="<%= ResolveUrl("~") %>Main_Content.aspx?open=Departments/HR/NewsLetter/newsletter_dec_2014.pdf">News Letter</a>

Now i want the text " News letter" to be shown on the redirected page.
I think i could this by saving the text in session variable.But How can I save the anchor text in Session variable without specifying any id or class to the anchor tag? Can anyone help me please ?


You can try this

$("a").click(function (e) {
    window.location.href = $(this).attr("href") + "&title=" + $(this).text();

On server side in "Main_Content.aspx"

strTitle = Request.QueryString["title"];