ASP.NET Tips To Increase Productivity and Simplify Maintenance – Part 4

ASP.NET Tips To Increase Productivity and Simplify Maintenance – Part 4

ASP.NET provides a robust framework for building Web applications that minimizes the amount of code that’s required to be written. Although most developers rely on Visual Studio or Web Developer Express when building applications, there’s no substitute for knowing the framework when it comes to increasing productivity. The more you know about built-in functionality in the .NET framework and ASP.NET, the less code you have to write, which ultimately makes your applications more maintainable.

This article outlines several different tips to enhance developer productivity and reduce the amount of code that needs to be written in many cases. Tips range from simple concepts, such as setting default focus on a control to creating your own FindControl() method. Although the tips focus on ASP.NET Web Forms, there is also information about Microsoft’s latest ASP.NET MVC framework as well. Let’s get started.

Set the Default Focus When a Page Loads

Have you ever visited a page to login and had to click in the first textbox in order to type? From an end user perspective, it’s much more efficient to automatically set the focus to the first control (such as a user name TextBox) as a page loads. That way they can start typing right away.

While setting the focus to a control can be done by writing custom JavaScript, ASP.NET has a built-in feature to handle this for you with no scripting code. This is accomplished by using the DefaultFocus property of the
HtmlForm control. By giving it the ID of the control that should have focus, it will automatically handle all of the behind-the-scenes code to make that happen. Here’s an example of using DefaultFocus.

The Page class also provides a way to programmatically set the focus to a control. Here’s an example of setting the focus to a control named txtUserName during Page_Load.

C#

Visual Basic

Focus can also be set directly on controls by calling the target control’s Focus() method. Here’s an example of calling a TextBox control’s Focus() method.

C#

Visual Basic

No #1 Recommended ASP.NET Hosting

ASPHostPortal.com

ASPHostPortal.com  is the leading provider of Windows hosting and affordable ASP.NET Hosting. ASPHostPortal proudly working to help grow the backbone of the Internet, the millions of individuals, families, micro-businesses, small business, and fledgling online businesses. ASPHostPortal has ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2015, .NET 5/ASP.NET 4.5.2, ASP.NET MVC 6.0/5.2, Silverlight 6 and Visual Studio Lightswitch, ASPHostPortal guarantees the highest quality product, top security, and unshakeable reliability, carefully chose high-quality servers, networking, and infrastructure equipment to ensure the utmost reliability.

HostForLIFE.eu

HostForLIFE.eu guarantees 99.9% uptime for their professional ASP.NET hosting and actually implements the guarantee in practice. HostForLIFE.eu is the service are excellent and the features of the web hosting plan are even greater than many hosting. HostForLIFE.eu offer IT professionals more advanced features and the latest technology. Relibility, Stability and Performance of  servers remain and TOP priority. Even basic service plans are equipped with standard service level agreements for 99.99% uptime. Advanced options raise the bar to 99.99%. HostForLIFE.eu revolutionized hosting with Plesk Control Panel, a Web-based interface that provides customers with 24×7 access to their server and site configuration tools.

DiscountService.com.au

DiscountService.com.au is The Best and Cheap ASP.NET Hosting. DiscountService.com.au was established to cater to an under served market in the hosting industry web hosting for customers who want excellent service. DiscountService.com.au guarantees the highest quality product, top security, and unshakeable reliability, carefully chose high-quality servers, networking, and infrastructure equipment to ensure the utmost reliability. DiscountService.com.au has ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2015, .NET 5/ASP.NET 4.5.2, ASP.NET MVC 6.0/5.2, Silverlight 6 and Visual Studio Lightswitch. DiscountService.com.au is devoted to offering the best Windows hosting solution for you.