The above example has few interesting features. Firstly note the @ Register directive in line 1 where a prefix to EXPERT and your control name to Logonform is set as shown below: -
| 1: <%@ Register tagprefix="EXPERT"Tagname="Logonform" Src="Logonform.ascx" %> |
This control can be used as a reference somewhere else with the code, as shown in line 5 as shown below: -
| 5: <EXPERT: Logonform id="Logon" runat="server"/> |
Further call_ascx.aspx page to the Logonform.ascx page and display the functions of user control as shown in the output snapshot above.
Validating ASP.NET Pages
Traditionally, Web developers face a tough choice when form validation logic is added to their pages. Addition of form validation routines can be done either on the server side code, or on the client side code. The advantage of writing validation logic at client side code is that it provides instant feedback to the users. For example, if a user ignores to enter a value in a required form field, an instant error message can be displayed without requiring a roundtrip back to the server. Client side validation is more useful and it creates a better overall user experience.
Configuring Client-Side Validation
The validation controls make use of a JavaScript script library, which is automatically installed on the server when .NET framework is installed. This library is located in file name WebUIValidation.js. By default WebUIValidation.js is installed in a directory named aspnet_client located beneath the Web server’s wwwroot directory.
If the location of the root directory is changed, it is important to copy the aspnet_client directory to the new directory, otherwise the validation script will not work and a warning error will be received as shown below.