Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to find application URL while using separate script file in asp.net ?

How to find application URL while using separate script file in asp.net ?

Scheduled Pinned Locked Moved ASP.NET
questioncsharpasp-nettoolstutorial
5 Posts 4 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zeego
    wrote on last edited by
    #1

    I am trying to find the url of webservice from a page inside a subdirectory in my website. I am using a separate script file referenced in my page. This does not work in the script file

    var pgUrl='<%= ResolveUrl("~/assets/WebServices/Admin/UsrRoleService.asmx") %>';

    How do I find the application url in the script file ?

    V S A 3 Replies Last reply
    0
    • Z zeego

      I am trying to find the url of webservice from a page inside a subdirectory in my website. I am using a separate script file referenced in my page. This does not work in the script file

      var pgUrl='<%= ResolveUrl("~/assets/WebServices/Admin/UsrRoleService.asmx") %>';

      How do I find the application url in the script file ?

      V Offline
      V Offline
      Vasudevan Deepak Kumar
      wrote on last edited by
      #2

      How about having script file in a .ASHX (Generic handler) so that ASP.NET can pre-process and send it...

      Vasudevan Deepak Kumar Personal Homepage
      Tech Gossips
      The woods are lovely, dark and deep, But I have promises to keep, And miles to go before I sleep, And miles to go before I sleep!

      1 Reply Last reply
      0
      • Z zeego

        I am trying to find the url of webservice from a page inside a subdirectory in my website. I am using a separate script file referenced in my page. This does not work in the script file

        var pgUrl='<%= ResolveUrl("~/assets/WebServices/Admin/UsrRoleService.asmx") %>';

        How do I find the application url in the script file ?

        S Offline
        S Offline
        Shahriar Iqbal Chowdhury Galib
        wrote on last edited by
        #3

        Try this code below

        var pgUrl='<%= this.Page.ResolveUrl("~/assets/WebServices/Admin/UsrRoleService.asmx") %>';

        A 1 Reply Last reply
        0
        • Z zeego

          I am trying to find the url of webservice from a page inside a subdirectory in my website. I am using a separate script file referenced in my page. This does not work in the script file

          var pgUrl='<%= ResolveUrl("~/assets/WebServices/Admin/UsrRoleService.asmx") %>';

          How do I find the application url in the script file ?

          A Offline
          A Offline
          AspDotNetDev
          wrote on last edited by
          #4

          By "script file", I assume you mean JavaScript file. You can't call server-side functions from a JavaScript file. You will have to find a way to pass the URL to the JavaScript. One way would be to pass the URL in via the constructor (you would presumably call the JavaScript constructor from an ASPX page in a script block). Though, I have found that I don't typically need to pass the URL of web services to the JavaScript if I am calling one of the methods using AJAX. Instead, I can add a service reference to the page's script manager (or in the case of a user control, the script manager proxy), then I can call the web service by name (e.g., ProjectName.UsrRoleService.SomeMethod(someParameter, function (resultData) { alert(resultData); });).

          Help a brotha out and vote Managing Your JavaScript Library in ASP.NET as the best ASP.NET article of May 2011.

          1 Reply Last reply
          0
          • S Shahriar Iqbal Chowdhury Galib

            Try this code below

            var pgUrl='<%= this.Page.ResolveUrl("~/assets/WebServices/Admin/UsrRoleService.asmx") %>';

            A Offline
            A Offline
            AspDotNetDev
            wrote on last edited by
            #5

            This will not work. The OP is trying to call ASP.NET code from an actual .JS file... that's not going to work.

            Help a brotha out and vote Managing Your JavaScript Library in ASP.NET as the best ASP.NET article of May 2011.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups