jueves, 23 de marzo de 2017

Alert() con salto de línea.

Muchas veces es necesario incluir en un alert varios mensajes de error, la siguiente solución esta planteada para vb.net y C# con Javascript.

VB.NET:
 
Dim strMensaje As String = ""
strMensaje += "- Ingrese texto A." + "\r\n"
strMensaje += "- Ingrese texto B." + "\r\n"
ScriptManager.RegisterStartupScript(Me, Me.GetType, "alerta", "alert('" & strMensaje & "');", True)

C#:
 
String strMensaje = "";
strMensaje += "- Ingrese texto A." + "\\n";
strMensaje += "- Ingrese texto B." + "\\n";
ScriptManager.RegisterStartupScript(this, this.GetType(), "alerta", "alert('" + strMensaje + "');", true);


Saludos.