Hi, I would like to know how I can get the javascript values of a Session variable of c#
that contains an array of strings.
The code is the following:
C#
:
if (Session["PolizasClientes_RowID"] != null)
{
Session.Remove("PolizasClientes_RowID");
}
var array = lstPolizas.Where(x => x.POLIZA == row_id).Select(x => x.DNI).ToArray();
var array2 = lstPolizas.Where(x => x.POLIZA == row_id).Select(x => x.POLIZA).ToArray();
string dni= array[0];
string poliza = array2[0];
string[] arrays = new string[] { dni, poliza };
Session["PolizasClientes_RowID"] = arrays;
Code javascript
to read the function that does not work for me (it returns System.string [1] or something like that if I read the entire session and if I put [0] it returns S):
var valores_sesion = '<%=Session["PolizasClientes_RowID"]%>';
//me devuelve System.string[1] o algo asi:
console.log(valores_sesion);
//me devuelve S
console.log(valores_sesion[0]);
//me devuelve S
console.log(valores_sesion[0][0]);
If instead of adding an array to the session, I add a single value if it works correctly, that is, with a code in c#
:
Session["PolizasClientes_RowID"] = arrays;
code in javascript
:
var valores_sesion = '<%=Session["PolizasClientes_RowID"]%>';
console.log(valores_sesion);
The result is the correct DNI.