tengo este codigo
var txt; function change(){ txt = "@Utils.GeneratePass()"; document.getElementById("password_field").value = txt; } function changeToHash(txt){ alert(window.txt); var password = "@Utils.Hash(txt)"; document.getElementById("password_field").value = password; }
En el método @Utils.Hash, necesito pasar una cadena y quiero poner el valor de txt. Pero recibí el error "El nombre 'txt' no existe en el contexto actual.
No puede pasar la variable js al código C#, puede intentar pasar @Utils.GeneratePass()
a @Utils.Hash()
:
var txt; function change(){ txt = "@Utils.GeneratePass()"; document.getElementById("password_field").value = txt; } function changeToHash(txt){ alert(window.txt); var password = "@Utils.Hash(Utils.GeneratePass())"; document.getElementById("password_field").value = password; }