Tweeter button
Facebook button
Technorati button
Reddit button
Myspace button
Linkedin button
Delicious button
Digg button
Flickr button
Stumbleupon button
Newsvine button

Posts Tagged microsoft

Using Validation Server Controls In ASP.NET

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

ASP.NET includes a number of useful server controls which can be used by developers to quickly add sophisticated functionality to a web form. The server validation controls provided by ASP.NET are used to check the information entered by visitors to your site into form fields and display error messages if there are problems with the entries. This process is referred to as validation and is an essential part of the information gathering process. Validation requires that you lay down some ground rules for each of the key fields in your form. How strict these rules are how strictly you enforce them is up to you. You will probably want to strike a balance between rules which are not so lax that they allow users to submit rubbish via your form and not so strict that they put users off.

Some types of control are more likely to require validation than others. For example, text boxes in which the user can choose to enter any information they like is likely to require more checking than a check box which can be checked or unchecked and nothing else. In addition, some fields will require multiple validation checks while others will require only one or perhaps none at all.

The Microsoft ASP.NET validation server controls provide web developers with both server-side and client-side validation. Server-side validation takes place on the server and is usually implemented using one of the two main languages used in ASP.NET web development: VB.Net or C#. Client-side validation takes place in the user’s browser and is usually done using JavaScript, before the form is sent to the server.

There are benefits and drawbacks to both client-side and server-side validation. From the user’s point of view, client-side validation is quicker and also frees up the server to perform other tasks. However, it is in no way secure. It is easy for the user to look at the source code of the page and see what type of validation is being performed. It is also possible for the user to disable the execution of JavaScript within their browser’s preferences.

The drawbacks found with server-side validation are that it is slightly slower and uses more of the server’s precious processing power. However, it is secure and allows developers to set up validation procedures which users cannot side-step.

Since both client-side and server-side have definite benefits, it is usually best to implement both of them when creating forms. The validation server controls found in ASP.NET make this very doable and very easy.

Does your team need to start ASP.NET website development? Macresource Computer Training offer Microsoft ASP.NET on-site courses in London and all over the UK.


Tags: , , , ,

Using Template Fields With The GridView Control In ASP.NET

The ASP.NET environment offers a number of built-in solution for displaying information from a database. One of the simplest ways of displaying databound data on an ASP.NET web page is to add a GridView control. The GridView can be created simply by opening the Database Explorer and dragging the table or view that from which you want to display information. However, the default GridView which is automatically generated in this way almost always needs some tweaking. One typical change you may want to make is to change some of the BoundFields elements to TemplateFields elements.

BoundFields are the default container for displaying data from a given column in the data source. By contrast, any content you desire can be placed inside a TemplateField element. This makes it ideal for setting up validation through the use of validation controls.

TemplateFields may contain static HTML/CSS, ASP.NET web server controls as well as databinding statements. They also offer great flexibility by allowing you to include a variety of templates to cater for the different states of the conditions arising within the GridView. There are several types of template which may be added inside a TemplateField object; the main ones are described below.

The HeaderTemplate offers a way of customizing the information which will be displayed in the header of the column in which the TemplateField is located.

Use the ItemTemplate to hold the information which you want displayed for each row of data when the GridView object is not selected for editing.

Use the EditItemTemplate to hold the information which you want displayed for each row of data when the GridView object is in edit mode. It is here that you would place the controls necessary for validation.

Typically, you would display the information currently held in the database by adding a TextBox control inside the EditItemTemplate and databind it to the appropriate column from the data source using a statement like Bind(“FirstName”). Inside the same EditItemTemplate, you would then place the necessary validation control. For example, if you want to ensure that the field is not left blank when the form is submitted, you would insert a RequiredFieldValidator control.

Need to master Using ASP.NET to build websites? We offer Microsoft ASP.NET on-site classes in London and all over the UK.


Tags: , , , ,

Powered by Yahoo! Answers