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 3302426
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:51:02+00:00 2026-05-17T20:51:02+00:00

Hey I have a question for javascript. I need to assign an href value

  • 0

Hey I have a question for javascript. I need to assign an href value to an anchor tag or asp:HyperLink. SOMETHING. that will allow me to link text in a dialog popup to an href that a function specifies. Here is my code.

<'custom:JQueryDialog I made' runat=server ID="dialogPopUp" AutoOpen="false"
   CloseOnEscape="true" Modal="true" Title="Download" width="300px">
    //I will spare you all of the div tags for formatting
    <a runat="server" id="downloadLink" target="_blank" class="'css with an icon'"
       href=""></a>
</'custom:JQueryDialog I made'>

Now I am having to get an fso from the database since that is where the info is stored. This fso is different depending on what the entity reflector class sends to this javascript. I have a function that formats javascript strings similar to C# I found. I then have another function that gets the fso from the entity reflector class. This works. I tested the string by displaying it in an alert and this works fine. The problem I am having is setting the href of the anchor tag with javascript. I am going nuts! Please help!

String Format:

String.format = function() {
    var s = arguments[0];
    for (var i = 0; i < arguments.length - 1; i++) {
        var reg = new RegExp("\\{" + i + "\\}", "gm");
        s = s.replace(reg, arguments[i + 1]);
     }
}

My attempt to change the href:

function changeHref(fso) {
    var downloadHref = String.format("Download.ashx?fso={0}", fso);
    $('#<%= this.downloadLink.ClientID %>').href = downloadHref;
    showDialog(<%= this.'custom dialog i made'.ClientID %>);
}

The download link is changed and everything. I just cannot seem to be able to set this! Am I missing the order of the page load? Do I need to do this after the whole page loads since items might not be generated yet? I tried a couple different things. I really could use a direction.

  • 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-17T20:51:02+00:00Added an answer on May 17, 2026 at 8:51 pm

    You can’t reference href directly like that from a jQuery object. All you are doing is creating a new property. Change it to set the attribute through attr like this…

    $('#<%= this.downloadLink.ClientID %>').attr("href", downloadHref);
    

    For completeness, I should mention that you can get to the underlying DOM element by using array syntax, and then you could set the href with regular Javascript…

    var domElem = $('#<%= this.downloadLink.ClientID %>')[0]; // DOM element is at 0
    domElem.href = downloadHref;
    

    Also, another probable error, I think you need quotes here…

    showDialog("<%= this.'custom dialog i made'.ClientID %>");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey all, I have something of an interesting requirement for my project. I need
Hey guys I have one more question lol. I am using a script that
Hey i have this div that shows as a popup: <div class=popup> </div> Then
Hey. I have an object that has a string property called BackgroundColor. This string
Hey this question is pretty general, but I'm wondering what the Javascript differences are
Hey guys, I have a bit of a problem that I can't solve. I'm
Hey ,Guys ,I have a question. I want to transform the array. [[1, [-1,
Hey I have a windows server running python CGI scripts and I'm having a
Hey all - I have an app where I'm authenticating the user. They pass
Hey right now I'm using jQuery and I have some global variables to hold

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.