ASP.NET

How to download a file from the Web server in ASP.NET in VB.NET

You should use the Directory FileInfo classes to collect and present the names of the files you want to make available for download to the end user. You can display their names in a ListBox with a button to initiate the download. When the user clicks the button, stream the selected file to the browser. The …

Learn more

How to download a file from the Web server in ASP.NET in C#

You should use the Directory FileInfo classes to collect and present the names of the files you want to make available for download to the end user.  You can display their names in a ListBox with a button to initiate the download. When the user clicks the button, stream the selected file to the browser.  The next picture …

Learn more

Data annotation support in ASP.NET 4.0

MVC 3 picks up some new, very useful validation features available due to .NET 4 support. For example:

–  MVC 2’s DisplayName attribute wasn’t localizable, whereas the .NET 4 standard System.ComponentModel.DataAnnotations Display attribute is.

–  ValidationAttribute was enhanced in .NET 4 to better work with the validation context for the entire model, greatly simplifying cases …

Learn more

Razor view engine in ASP.NET 4.0

The default view engine used in MVC 2 is called Web Forms View Engine, because it uses the same ASPX/ASCX/MASTER files and syntax used in Web Forms. Razor was designed specifically as a view engine syntax. It has one main focus: code-focused templating for HTML generation.

To see the differences between two view engines two markups related to the …

Learn more

How to use Validation groups in ASP.NET 4.0

In more complex pages, you may want to perform validation separately, by using several distinct groups of controls, possibly in separate panels. ASP.NET 4.0 enables this scenario with a feature called validation groups. To create a validation group, you need to put the input controls and the CausesValidation button controls into the same logical group. You can do …

Learn more

How to use CustomValidator control in ASP.NET 4.0

You can use the CustomValidator control to execute your custom client-side and server-side validation routines. You can associate them with the control so that validation is performed automatically. If the validation fails, the Page.IsValid property is set to false, as occurs with any other validation control.

 

The client-side and server-side validation routines for the CustomValidator are declared similarly. They …

Learn more

How to use RegularExpressionValidator control in ASP.NET 4.0

The RegularExpressionValidator is one of ASP.NET’s most powerful validation controls. It validates text by determining whether it matches a specific pattern. All regular expressions consist of two kinds of characters:

– Literals – represent a specific defined character

– Metacharacters –  characters for special use.

When you are going to use RegularExpressionValidator you should develop regular expression …

Learn more

How to create a manual validation in ASP.NET 4.0

You can create a manual validation in one of the three ways:

– Use your own code to verify values. In this case, you will not use any of the ASP.NET validation controls.

– Disable the EnableClientScript property for each validation control. This allows an invalid page to be submitted, after which you can decide what …

Learn more

How to use RequiredFieldValidator control in ASP.NET 4.0

RequiredFieldValidator is the simplest available control in ASP.NET. You can use it to ensure that the associated control is not empty. For example, the control will fail validation if a linked text box doesn’t contain any content or contains spaces. Instead of checking for blank values you can specify a default value using the InitialValue property. In this …

Learn more