'Set Enter on keypress to start search asp.net c#
I've a page with a GridView and a search textbox with his button near to it and i want to set that when the user press "ENTER" start the search and only that. I don't know how to set this thing in ASP.NET C#.
And how can I do to modify the style of:
Messaggio_Ricerca.Text = " I caratteri inseriti nella barra di ricerca non sono validi. "
when it comes out ?
ASP Code:
Ricerca :
<asp:TextBox ID="CampoRicerca" runat="server" CssClass="textbox" Width="300px" Height="25px" Placeholder="Inserisci qui i dati che vuoi cercare" ></asp:TextBox>
<asp:Button ID="BTN_Ricerca" OnClick="Ricerca_NomeInserito" runat="server" Text="" Width="35" Height="35" CssClass="ricerca"></asp:Button>
<asp:Label ID="Messaggio_Ricerca" runat="server"></asp:Label>
C# Code:
protected void Ricerca_NomeInserito(object sender, EventArgs e)
{
this.RicercaCliente();
}
private void RicercaCliente()
{
//String query code
if (String.IsNullOrWhiteSpace(CampoRicerca.Text))
{
Messaggio_Ricerca.Text = " I caratteri inseriti nella barra di ricerca non sono validi. ";
}
else
{
//SqlCommand code
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
