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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:00:42+00:00 2026-06-05T10:00:42+00:00

How do I code the equivalent of an @Html.ActionLink through javascript code i.e. call

  • 0

How do I code the equivalent of an @Html.ActionLink through javascript code i.e. call an MVC action which will then create a new View without coming back to the calling view?

  • 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-06-05T10:00:44+00:00Added an answer on June 5, 2026 at 10:00 am

    javascript is a client side language which doesn’t know anything about the server side language you are using. Thus it is normal that there’s no equivalent in javascript of the server side helper that generates an url using your server side route definitions.

    It is not quite clear what you are trying to achieve but if you want to use call some url through javascript you could generate this url using a server side helper:

    <script type="text/javascript">
        var url = '@Url.Action("SomeAction", "SomeController")';
        // do something with the url client side variable, for example redirect
        window.location.href = url;
    </script>
    

    If you want to use this url in a separate javascript file where you don’t have access to server side helpers you could still, depending on the situation, include this url in some DOM element.

    For example:

    <div id="foo" data-url="@Url.Action("SomeAction", "SomeController")">Click me</div>
    

    Notice the data-url HTML5 attribute that we have embedded into the DOM and used a server side helper to ensure that the generated url will always be correct based on our routing definitions. Now we could in a separate javascript file unobtrusively subscribe to the click event of this div and retrieve the url:

    $('#foo').click(function() {
        var url = $(this).data('url');
        // do something with the url client side variable, for example redirect
        window.location.href = url;
    });
    

    Other examples obviously include the standard <a> and <form> elements which should be generated using server side HTML helpers and then all you have to do in your separate javascript file is to fetch their corresponding href or action attributes to retrieve the actual url and do something with it.

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

Sidebar

Related Questions

I'm pretty new to MVC, but I have the following code: <td> @Html.DisplayFor(modelItem =>
I have this jQuery code which replaces some HTML character codes with their equivalent:
I want to write the following C# code equivalent in JavaScript/jQuery (x == 0
What is the equivalent code in jQuery for the below JavaScript function? function attachSomeHandler(in)
I need a pure JavaScript equivalent of this Jquery code: because the use of
Can anyone tell the block animation equivalent of this below code snippet? [UIView beginAnimations:@View
I am trying to write PHP code to loop through an array to create
I'm just trying to get the equivalent HTML code that represent a specific control
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am trying to construct equivalent of this code in JSF2 <form action=/search.xhtml method=get>

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.