C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Handling Enter Key - ASP.NET 2.0 Default Button


Posted Date: 07 Mar 2007    Resource Type: Code Snippets    Category: ASP.NET WebForms

Posted By: Harish Ranganathan       Member Level: Gold
Rating:     Points: 10



Handling the Enter Key is one of the challenges faced by Web Developers and one has to resort to different means like writing Javascript to handle the enter key event. With ASP.NET 2.0, there is a DefaultButton property for Forms, Panels etc., which can help you in handling the enter key in an efficient way. This scenario explains a basic Enter Key Functionality.

The Code below shows the ASPX Design and the Controls Declaration

Note the Default Button (defaultButton="Button3") property of the form tag. This determines, which Button Click to fire when the Enter Key is pressed.









































The Code below shows the C# Code behind. Note that the significance of this example is in the above code snippet (Design and Control Declaration) and the code behind is just to have Button Click Events to do a Response.Write of respective Button Name.


protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "Button 1 is Clicked !";
}
protected void Button4_Click(object sender, EventArgs e)
{
Label1.Text = "Button 4 is Clicked !";
}
protected void Button3_Click(object sender, EventArgs e)
{
Label1.Text = "Button 3 is Clicked !";
}
protected void Button2_Click(object sender, EventArgs e)
{
Label1.Text = "Button 2 is Clicked !";
}




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Formating the Price to two decimals in DataGrid
Previous Resource: Handling Enter Key in Multiple Sections of a Page - ASP.NET 2.0 Default Button for Panels
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET WebForms


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

web conferencing

Contact Us    Privacy Policy    Terms Of Use