Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

186
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda