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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:49:48+00:00 2026-05-15T03:49:48+00:00

I have some javascript inwhich I am using such helpers as var url =

  • 0

I have some javascript inwhich I am using such helpers as

var url = <%=ResolveUrl("~/controller/action") %> 

When the javascript is embeded in the .aspx page using the

<script> tag everything works fine

When I move it out to an external file those scripts that have the helper methods do not work.

Other scripts do just the ones with the

var url = <%=ResolveUrl("~/controller/action") %>

do not.

Are these not possible to use in external javascript files??

I would like to get all of my javascript out of the aspx files if I can.

thanks!

  • 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-15T03:49:48+00:00Added an answer on May 15, 2026 at 3:49 am

    ResolveUrl is a helper method of the Control class which is why you are able to call them from ViewPages (ending in .aspx)

    You can’t call these from javascript because those files are treated as simple assets with no compilation.

    What you can do, however, is set variables for those paths you need in the master page or view page and reference them from the js files. An even better solution is to keep the URLs you need in the document, such as in <a> tags and use javascript to fish them out whenever actions are performed:

    For instance, this jquery code fetches the url from an <a> tag and replaces the tag with the html content from an ajax call.

    $('a#clickme').click(function() {
        var $this = $(this);
        $.ajax({
            type: 'GET',
            url: $this.attr('href'),
            success: function(data) {
                $this.replaceWith(data);
            },
            failure: function(data) {
                alert('Handle this error gracefully');
            }
        });
        return false;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 489k
  • Answers 489k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Your first step is probably going to be to determine… May 16, 2026 at 9:00 am
  • Editorial Team
    Editorial Team added an answer Number of things: When your class template is instantiated once… May 16, 2026 at 9:00 am
  • Editorial Team
    Editorial Team added an answer You can avoid this by making your device find the… May 16, 2026 at 9:00 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have already implemented some AJAX pagination in my Rails app by using the
1) couple of HTML files in which javascript is embeded..... My Requirements 1) I
I have a job model which has many attributes. I would like to use
What I am doing is creating a simple html page in which there is
I have a MySQL table of people as part of a web site, for
I'm fairly new to jQuery still and am trying to pick up ways to
I came from a Windows background whern it comes to development environments. I'm used
I've been reading about Stanford's Secure Remote Password protocol , and it looks ideal
I'm fairly new to Zend Framework and MVC in general so I'm looking for

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.