Tuesday 8 November 2011

Extender to any control in the WebApplication

Question Received:
       To add an extender to any control in the web page.

Solution:
       Add it like,
        <asp:RegularExpressionValidator
                                        ID="RegExValidatorCommonGroup"
                                        runat="server"
                                        ControlToValidate="anyTxtBox"
                                        ErrorMessage="Requires valid Text"
                                        ValidationExpression="(Expression_)+[1234]$" 
                                        ValidationGroup="CommonGroup">
       </asp:RegularExpressionValidator>
       <asp:TextBox
                       ID="anyTxtBox"
                       runat="server"
                       Width="250px"
                       ValidationGroup="CommonGroup">
      </asp:TextBox>
     <asp:Button
                   ID="AnyBtn"
                   runat="server"
                   Text="OK"
                   onclick="AnyBtn_Click"
                   ValidationGroup="CommonGroup">  
    </asp:Button>

All Controls in the same group will be triggered for validation.
[Note:] Please do care about the ValidationGroup. Else, All controls in the
page will be triggered for validation.

No comments:

Post a Comment