Thursday, May 3, 2012

How to add custom error message into ValidationSummary on server side in ASP.NET webform?

On server side event handler, add following code:
                CustomValidator val = new CustomValidator();
                val.IsValid = false;
                val.ErrorMessage = "Error ";
                this.Page.Validators.Add(val);

http://blog.webmastersam.net/post/Adding-custom-error-message-to-ValidationSummary-without-validators.aspx

Wednesday, May 2, 2012

Security and the ASP.NET View State

http://radicaldevelopment.net/security-and-the-asp-net-view-state/
<pages enableViewState="true" enableViewStateMac="true" viewStateEncryptionMode="Auto"></pages>

Tuesday, May 1, 2012

How to valid email address by custom validation control and JavaScript regular expression in ASP.NET webform?

     <script type="text/javascript">
        function EmailValidation(sender, args) {
            var email = $("#TextBoxEmailAddress").val();
            var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
            args.IsValid = re.test(email);
        }
    </script>
    <asp:TextBox ID="TextBoxEmailAddress" runat="server" ClientIDMode="Static"></asp:TextBox>
    <asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Invalid email"
        ClientValidationFunction="EmailValidation" ControlToValidate="TextBoxEmailAddress"></asp:CustomValidator>

Custom errors and error detail policy in ASP.NET Web API

http://lostechies.com/jimmybogard/2012/04/18/custom-errors-and-error-detail-policy-in-asp-net-web-api/