I have a Login user control in a Login form. I want to set the default Enter press to a button called LoginButton in my user control.How can I do it in C# using Visual studio ?

Recommended Answers

All 4 Replies

I think that what you need to do is add a key listener to the form.

Which then checks to see if the enter button was pressed and if so fires a method you call when the button is actually clicked.

Soecify defaultbutton property in form tag

<form id="form1" runat="server" defaultbutton="Specify the button ID">

Hi renukavani

Just wrap you code in asp:panel like this...

.aspx

<asp:Panel ID="Panel1" runat="server" DefaultButton="Button1">
         <asp:Label ID="Label1" runat="server" Text=""></asp:Label>
    </asp:Panel>
    <asp:Button ID="Button1" runat="server" Text="Button" />
    <asp:Button ID="Button2" runat="server" Text="Button" />

Mark as solved if it helps you

thx reach_yousuf, worked like a charm!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.