Can a javascript function be executed from a Controller with an ActionResult?

0

I do not know if I can but I need to execute a javascript instruction that returns a value to me. But I need to do it from an ActionResult of a controller in ASP.NET MVC

Clarification: I already know that it is a client code in the server code but I just wanted to know if you can ...

For example:

Public ActionResult GetInfo(){

  //Ejecutar una funcion de javascript y que me devuelva un valor
  // <script>GetPermission(){ return Notification.permission;}</script>
  // Y usar GetPermission ya en c# del lado del servidor
  // string _permission= GetPermission();

  return View();
}

Thanks to the whole community!

    
asked by Manuel Leone 23.06.2018 в 02:31
source

1 answer

0

If you can do something similar

 MVELEntitiess dbCont = new MVELEntitiess();
        var count = from query5 in dbCont.tb_fuente_parametro//Query para comparar datos obtenidos de excel con la DDBB si es != de null se actualiza
                    where query5.Manual.ToString().ToLower() == ("S").ToString().ToLower() && query5.Codigo_fuente.ToString() == ("7").ToString()
                    select query5.Manual;

        var contador = "";
        if ((count != null) && (count.Count() > 0))
        {

            contador = (count).ToString();

        }
        ViewData["bloquear"] = contador;//Envio un viewdata al js que lo recibo como "Bloquear"


        return View("~/Views/CargaCMGmt/CargaCMGmt.aspx");
    }

Here is the view

<script type="text/javascript">
             <% if (ViewData["bloquear"] == "") //Si bloquear esta vacío bloqueo mi boton Submit y de esta manera recibo el parametro desde el controlador
        { %>
        $("#botoncargar").attr('disabled', 'disabled');

        <% } %>
    </script>
    
answered by 27.06.2018 / 17:15
source