Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

189
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda