I´m using blur event, so i check the length of the textbox when the length is more than 25, the idea is show a error message, but so far i cant show the message.
page.ClientScript.RegisterStartupScript(page.GetType(), "SweetAlert", pMensaje, false)-> this is where i am supposed to show the message, right now i cant see anythig
<div class="grid3_1">
<asp:Label runat="server" Text="Ubicación Exacta"></asp:Label>
<asp:TextBox ID="txtDireciónExacta" CssClass="item19" style="resize:none" Height="100%" runat="server" Rows="5" TextMode="MultiLine"></asp:TextBox>
<asp:Label runat="server" Text="#Plano"></asp:Label>
<asp:TextBox ID="txtNumPlano" CssClass="item21" runat="server"></asp:TextBox>
<asp:Image runat="server" CssClass="item22" ImageUrl="~/images/balloon_basic_blue.png" />
<asp:Label runat="server" CssClass="item23" Text="Folio Real"></asp:Label>
<asp:TextBox ID="txtFolioReal" CssClass="item24" runat="server"></asp:TextBox>
<asp:Label runat="server" CssClass="item25" Text="Area"></asp:Label>
<asp:TextBox ID="txtArea" CssClass="item26" runat="server"></asp:TextBox>
<asp:Label runat="server" CssClass="item27" Text="Finca Madre"></asp:Label>
<asp:TextBox ID="txtFincaMadre" CssClass="item28" runat="server"></asp:TextBox>
<asp:Label runat="server" CssClass="item29" Text="Tipo de Trámite"></asp:Label>
<asp:DropDownList ID="droplistTipoTramite" CssClass="item30" runat="server" Height="30px">
</asp:DropDownList>
<asp:Label runat="server" CssClass="item31" Text="Servidumbre"></asp:Label>
<asp:TextBox ID="txtServidumbre" CssClass="item32" runat="server"></asp:TextBox>
</div>
<script>
window.onload = function () {
let txtnumplano = document.getElementById('<%=txtNumPlano.ClientID%>');
if (txtnumplano) {
txtnumplano.addEventListener('blur', () => {
PageMethods.LongitudTxtNumPlano(txtnumplano.textLength);
});
}
}
</script>
[System.Web.Services.WebMethod()]
[System.Web.Script.Services.ScriptMethod()]
public static void LongitudTxtNumPlano (string caracteres){
pMensaje = vMensajes.mostrarMensaje("No empty", "error", "Atención");
int count=int.Parse(caracteres);
if (count> 25)
{
Page page = (Page)HttpContext.Current.CurrentHandler;
page.ClientScript.RegisterStartupScript(page.GetType(), "SweetAlert", pMensaje, false);
}
}