Primero creamos una pagina web con una caja de Texto:
1 2 3 4 5 6 7 8 9 10 11 12 13 | <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Example.aspx.cs" Inherits="Example" %> < head runat = "server" > < title >Untitled Page</ title > </ head > < body > < form id = "form1" runat = "server" > < div > < asp:TextBox Id = "txtTexto" runat = "server" ></ asp:TextBox > </ div > </ form > </ body > </ html > |
Seguidamente creamos un botón asp.net dentro de un <div> oculto así:
1 2 3 | < div style = "display: none;" > < asp:button id = "btnTextBox" runat = "server" onclick = "btnTextBox_Click" > </ asp:button ></ div > |
Quedando la pagina:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Example.aspx.cs" Inherits="Example" %> < head runat = "server" > < title >Untitled Page</ title > </ head > < body > < form id = "form1" runat = "server" > < div > < asp:TextBox Id = "txtTexto" runat = "server" ></ asp:TextBox > </ div > < div style = "display: none;" > < asp:button id = "btnTextBox" runat = "server" onclick = "btnTextBox_Click" > </ asp:button ></ div > </ form > </ body > </ html > |
Ahora en el evento Page_Load de la pagina agregar el atributo al cuadro de texto:
1 2 3 4 | protected void Page_Load( object sender, EventArgs e) { txtTexto.Attributes.Add( "onblur" , this .Page.ClientScript.GetPostBackEventReference( this .btnTextBox, "" )); } |
Finalmente agregamos el código en el evento clic de nuestro botón oculto.
1 2 3 4 | protected void btnTextBox_Click( object sender, EventArgs e) { //Coloque aquí su código para evento onblur } |
"" Si tienes dudas o quieras ampliar este artículo, lo puedes hacer dejando tus comentarios. Además, si lo consideras interesante puedes compartirlo con amigos y seguidores a través de los botones sociales que aparecen en esta página.""
Blogging is the new poetry. I find it wonderful and amazing in many ways.
ResponderEliminarThanks for your feedback Mobile App Developers , Greetings
ResponderEliminar