[C#] Comment valider un bouton en appuyant sur la touche entrée ?
Salutations a tous et a toutes
bien que j ai eu tres souvent a consulter cette platteforme c est bien la premiere fois que je y viens soumettre un probleme.
- je travaille sur une page en ASP.Net et butte devant une difficulte, celle de pas pouvoir : valider un boutton "recherche" en appuyant simplement sur la touche d "Entree" du clavier (et cela bien sur apres avoir ecris un mot clef dans le TextBox prevu a cet effet)
voici mes lignes de code en c# j espere que quelqu un voudra bien y jetter les foudres de sa Science ;)
Code:
1 2 3 4 5
| protected void btnSearch_Click(object sender, EventArgs e)
{
Session.Add("project__searchword", txtSearchProj.Text);
Response.Redirect("project_search.aspx");
} |
Merci merci remerci encorrr
Solution Simple et Efficace !!!
je viens d avoir une solution tres simple a mon Probleme, d un chargé du marketing de VS2005 chez Microsoft germany GmbH (un Evengeliste comme ils disent :-) )
Explication en Anglais
With ASP.NET 2.0 you can now also set a "defautfocus" property on the <form> tag to control this as well. You can likewise set this programmatically using the Page.SetFocus(control) method where you pass in a reference to a control, or by calling a "Focus()" method now surfaces on ASP.NET TextBox and other input controls on the server
Citation:
<html>
<body>
<form defaultfocus=“textbox2” defaultbutton=“button1” runat=“server”>
<asp:textbox id=“textbox1” runat=“server”/>
<asp:textbox id=“textbox2” runat=“server”/>
<asp:button id=“button1” text=“Same Page” runat=“server”/>
<asp:panel defaultbutton=“button2” runat=“server”>
<asp:textbox id=“foo” runat=“server”/>
<asp:button id=“button2” runat=“server”/>
</asp:panel>
</form>
</body>
</html>
Merci a graphicsxp & CORBASE d avoir assure mon batême sur le site
a bientot :aie: