Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

185
Views
on page load call controller method using data from query string

Is it possible to retrieve query string data on page load using javascript? Let me explain my sample project in steps::

  1. I have a view page showing tabular data. On button press, it retrieves id of the row and calls javascript function.

  2. This javascript function, getDetails(id) has to call another view page, say Application.cshtml.

  3. I have to pass the value of id and a variable message to this view page Application.cshtml.

  4. I am trying to pass this as query string.

  5. Now in this view page Application.cshtml, I have to retrieve the value of id and call contoller method to show the details of the id on page load.

  6. Is it possible to do using javascript?

    function getDetails(id)

    {

     var message = "testing";
     var id_ = id;
     window.location = "/FirmModels/Application/" + id_;        
    

    }

My problem is how can I retrieve the value of id and call controller method on page load using javascript in Application.cshtml?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Your question is a bit unclear but as far as I understood this question you can do this in two ways.

Assuming that you have something like this in your JS file.

window.location = "/Controller/Application?id= " + id_;

In the first method, the View inside your Controller will look like this

public ActionResult Application()
    {
        string id= Request.QueryString["id"];
        //Do your operations here
        return View();
    }

The second way to do this to pass the id as a mandatory parameter to the view.

public ActionResult Application(string id)
    {
        return View();
    }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!