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

  • Home
  • SEARCH
  • 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'm writing some jquery to programmatically build a list of links and I'd like
I am having log4net permission issue from ASP.Net 4.0 web application to write to
I have links on my web page that are called like this: <a href=/xxx/
Integrating SimpleModal with ASP.NET I want to thank Eric for producing SimpleModal and compliment
I'm having hard time understanding the following C# code. This code was taken from
So, using a HTML 5 compliant video player, (like Video JS) how would one
I'd like to implement a functionality in an app of mine, but I don't
I'll try this again. I'm having trouble figuring out how to work with the
having trouble deciding whether or not it makes sense to put paging information about
I'm having a bit of trouble finding a nice little jquery plugin that would

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.