Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3233334
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:15:54+00:00 2026-05-17T17:15:54+00:00

I am having links like: <asp:HyperLink ID=lnkTitle runat=server CssClass=itemTitle > </asp:HyperLink> <a id=linkOwner runat=server

  • 0

I am having links like:

<asp:HyperLink ID="lnkTitle" runat="server" CssClass="itemTitle" >
                                </asp:HyperLink>
<a id="linkOwner" runat="server" class="authorName"></a>

I am assigning the NavigateUrl from code behind at run time like:

 lnkTitle.NavigateUrl = "MyPage.aspx?id=" + userID;

 linkOwner.HRef= "MyPage.aspx?id=" + userID;

(where userID is an integer type variable)I need to access the id value from the navigate url in js file for both the cases. How access it by using jquery?Can anyone help me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T17:15:54+00:00Added an answer on May 17, 2026 at 5:15 pm

    Two possible options

    • In jQuery, obtain the href attribute of the generated link, and extract the userId from there : the code-behind you are typing will result in the generation of something like

    <a href="MyPage.aspx?id=1234" id="SomeCrazyIDGeneratedByASP.NET">text of the link</a>

    the problem here, is that the ID of the generated link may vary … which makes the link harder to find in the page using a jQuery selector. I would suggest adding a specific CSS class to your links, for instance user-page. Then you could do something like this, I suppose :

    /*extract the href attribute from the link, and get the item after the last "=" sign*/
    var href = $('a.user-page').attr('href');
    var split = href.split("=");
    /*reverse it and take the first item (used to be last)*/
    var userId = split.reverse()[0];
    alert(userId);
    
    • The other option I usually prefer is to expose a server-side variable such as userId directly in Javascript… In order to do that, you must make userId visible from the .aspx file. Then in your .aspx file, do something like that

      <script type="text/javascript">
      var userId = <%=userId%>;
      alert(userId);
      </script>

    Then you can use it as any javascript variable !

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page using a Treeview server control like so: <asp:TreeView ID=uxTreeView ShowExpandCollapse=True
I'm using the asp.net MVC pattern of having a url like controller/action/id . This
I have the following repeater <asp:Repeater id=weatherFeed Runat=server><ItemTemplate> <asp:LinkButton runat=server id=PickInfo onClick=Selection_PickInfo> <img src=images/mapPin.png
i am having the link like <a href=http://twitter.com/home/?status='.$markme_ddesc.' onclick=OpenPopup(this.href); return false>Click Here to See
I my application i am having three links, on clicking the link i need
In left menu bar i am having two links about and messages while clicking
I am having a Xpage with some links. One of my link call EXIT
I've been having problems getting jqmodal modal dialogs to display on links added dynamically
A Webview will display links in the content HTML as having blue underlines. So
I am having problems with echoing the result from a sql query as links

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.