Attention: We are retiring the ASP.NET Community Blogs. Learn more >

Contents tagged with Web Forms

  • Using Validation Groups Inside ASP.NET User Controls

    Validation groups allow you to validate data entry controls in groups. Server controls such as validation controls, Button and TextBox have ValidationGroup property that takes a string value. All the server controls having the same ValidationGroup value act as one validation group. Validation groups come handy in situations where you wish to validate only a small set of controls from many controls housed on a Web Form. Using validation groups is quite easy and straightforward. However, if you have a validation group inside a user control and there are more than one user control instances on a Web Form you face some problem.

  • Displaying File Upload Progress using jQuery UI Progressbar Widget

    While uploading large files you may need to display the progress of the file upload operation to the end user. This can be done using HTML5 and jQuery UI's Progressbar widget. While HTML5 also has progress element that can be used to render a progress bar, jQuery UI's Progressbar widget offers more configuration and theming options. In this post you will use XMLHttpRequest (Level 2) object to upload files to the server. The XMLHttpRequest object now supports file upload related events such as progress that can be used to track file upload progress.

  • Using Value Providers in ASP.NET 4.5

    ASP.NET 4.5 Web Forms support model binding. A part of the overall model binding features are Value Providers. A value provider grabs values from a request and binds those values with method parameters. ASP.NET provides several inbuilt value providers and also allows you to create your own. This article discusses what value providers are with examples. It also shows how a custom value provider can be created.

  • Using HTML5 Date Input Type Inside GridView

    HTML5 provides several new input types such as email, URL and Date. While using Date input type a textbox is displayed as a date-picker by browsers such as Chrome and Opera. Such a textbox uses dates in yyyy-MM-dd format (ISO format) and this formatting can lead to some problems in data controls such as GridView as discussed below.

  • Ajax Based Polling in ASP.NET Web Forms and MVC

    Recently a reader asked as to how Ajax polling can be implemented in ASP.NET applications. This short post attempts to answer that question. In the SSE and SignalR techniques mentioned earlier the server sends a notification to the client whenever some interesting event happens on the server. On the other hand Ajax base polling involves the client side code periodically checking the server for some status change.

  • Validating Multiple Data Model Properties

    In my previous article I wrote about displaying model state errors inside databound controls such as GridView. In that example we used data annotation validators to perform the validations. While data annotation validators do their job quite well they are inherently applied to only one data model property at a time. For example, the [StringLength] or [Required] attributes validate only one property under consideration. However, sometimes your validation rule involves multiple data model properties. In such cases data annotation validators won’t be of much use. Luckily there are other validation techniques that can come to your rescue.

  • Two Ways of Passing HTML5 Web Storage Data to ASP.NET

    HTML5 web storage allows you to store data on the client side. However, unlike cookies this data is not passed automatically to the server with every request-response cycle. To pass the data stored in web storage to the server you need to make some programmatic arrangement. Two ways by which such a data transfer can be facilitated are hidden form field and Ajax call. This article explains both of these techniques with an example.

  • Displaying Model State Errors Inside GridView Columns

    ASP.NET 4.5 web forms support model binding features. Additionally they can make use of model validation using data annotation validators. The validation errors thrown by data annotation validators can be easily displayed in a web form using ValiationSummary control. While this arrangement works great, at times you want something customized. This article shows how model errors can be displayed inside a GridView column. You can use similar technique for other databound controls such as DetailsView and FormView.

  • Two ways of selecting files for uploading

    As you know HTML5 has native support for drag and drop operations. A part of this support also allows you to drag files from Windows explorer and drop them on to a web page element. The files can then be uploaded on the server as usual. In addition to HTML5 drag-n-drop you may want to allow users to use classic technique of file selection - displaying an open file dialog and let them select the files. If you are supporting both the types of file selection techniques you may want to hide the File Upload server control from being displayed on the form entirely because generally you will have some other element (usually a graphical element) on which the end user can drop the files.