Tuesday, 18 December 2012

Define Maximum Value of a multiline TextBox in Asp.net Application

Asp.Net gives invariably a cool and very good built properties in controls like MaxLength property for a TextBox which doesn’t allows a user to enter more than the specified length. But this property do not work well with a MultiLine TextBox (TextMode= MultiLine).

To resolve this problem one can either use a JavaScript function to check the number of characters entered in the MultiLine TextBox and then return false in case the value exceeds the developers expected length.

The other and a much simpler way to do this is to use a RegularExpressionValidator Control.

This can be done in following steps:-
1. Drag and drop a RegularExpressionValidator and set its ControlToValidate property to the multiline TextBox.

2. In the ExpressionValidation write the expression :
^[\s\S]{“Your Minimum Length,”Your Maximum Length”}$

Example:- ^[\s\S]{3,10}$

where ^ denotes start of string, \s\S denotes spacial and non-spacial characters and {3,10} denotes minimum of three and a maximum of 10 characters can be entered. $ represents the end of string

Friday, 14 December 2012

Disable browser back button after authentication in asp.net application

To disable back button After login 
Place this code in the HTML head section of  Login.aspx  page

    <script type="text/javascript" language="javascript">
        function preventBack() { window.history.forward(); }
        setTimeout("preventBack()", 0);
        window.onunload = function () { null };


Tuesday, 4 December 2012

Total Pageviews