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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:28:40+00:00 2026-05-20T09:28:40+00:00

I have a question about jQuery + Razor.. I want to build a javascript

  • 0

I have a question about jQuery + Razor.. I want to build a javascript variable using razor with @Url.Action and the html attributes will be values of inputs.
Like this:

var d1 = $('#d1').val();
var d2 = $('#d2').val();
var url = "@Url.Action("Links", "PartialAccount", new { beginDate = "d1", endDate = "d2" })"
$("#links").fadeOut("slow").load(url).fadeIn("slow");

How can I do this?

Is it the same that below?
var url = "/PartialAccount/Links/?beginDate=" + d1 + "&endDate=" + d2;

  • 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-20T09:28:40+00:00Added an answer on May 20, 2026 at 9:28 am

    You should use the load method as proposed by InfernalBadger:

    load('@Url.Action("Links", "PartialAccount")', { beginDate: d1, endDate: d2})
    

    because this will encode the parameters in d1 and d2 correctly. But only if you can pass the parameters as part of the querystring, not when they should be a part of the url itself.

    So you can use if you want your url to be:

     /bar/foo?beginDate=1-1-2001&endDate=2-2-2001
    

    (note that the /’s in the date will be encoded)

    You cannot use this if you want your url to be:

    /bar/foo/1-1-2001/2-2-2001
    

    The @Url method, with the beginDate and endData parameters, does not work, because this is executed on the server, before the page is send to the browser.

    And your method by using the + operator fails the user enters “special characters” in the input boxes (like dashes /).

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

Sidebar

Related Questions

I have a quick question about jquery .. I want to find < a
I have a jquery question about selecting Id. Basically, I call a javascript function
I have a question about using streams in .NET to load files from disk.
I have a question about using os.execvp in Python. I have the following bit
I have a question about using new[] . Imagine this: Object.SomeProperty = new[] {string1,
I have quick question about jQuery plugins, hope somebody out there has some advice.
Total beginner question about jQuery: I have a Form that contains several TextBoxes (input
I'm new here and I'd like to ask a question about jQuery. I have
I have a question about some functionality I'm trying to add to my jQuery
I have question about NSView: Imagine a Custom View where the mouseDown, mouseDrag and

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.