Click here to Skip to main content
15,888,454 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionExport Gridview data to excel in asp.net Pin
Member 128096229-Dec-16 22:16
Member 128096229-Dec-16 22:16 
AnswerRe: Export Gridview data to excel in asp.net Pin
Michael_Davies9-Dec-16 22:24
Michael_Davies9-Dec-16 22:24 
QuestionRe: Export Gridview data to excel in asp.net Pin
Richard MacCutchan9-Dec-16 23:15
mveRichard MacCutchan9-Dec-16 23:15 
AnswerRe: Export Gridview data to excel in asp.net Pin
Afzaal Ahmad Zeeshan10-Dec-16 1:18
professionalAfzaal Ahmad Zeeshan10-Dec-16 1:18 
QuestionPopulate textboxes on dropdown selection using mvc4.net sqlserver2013 Pin
Member 104841628-Dec-16 9:40
Member 104841628-Dec-16 9:40 
AnswerRe: Populate textboxes on dropdown selection using mvc4.net sqlserver2013 Pin
ZurdoDev9-Dec-16 3:31
professionalZurdoDev9-Dec-16 3:31 
QuestionHow to bypass fields that have required validation to go to next page Pin
Bootzilla338-Dec-16 6:56
Bootzilla338-Dec-16 6:56 
AnswerRe: How to bypass fields that have required validation to go to next page Pin
jkirkerx8-Dec-16 8:08
professionaljkirkerx8-Dec-16 8:08 
I did it using manual validation and jQuery.Validator.js. for MVC
I never used the validator for WebForms.
But I would remove your validators and go manual.

I wrote a jquery script called load_cc_validator and called it when I toggled the form module in jquery.

So I wrote the HTML in Razor and manually assigned the values
<h4>Card information</h4>
<div class="form-group">
  @Html.Label("Edit_CC_FirstName", "First name on card", new { @class = "control-label" })
      <div class="input-group">
        @Html.TextBox("Edit_CC_FirstName", "", new { @class = "form-control", data_val = "true", data_val_required = "Card first name required", placeholder = "First name on card" })
        @Html.ValidationMessage("Edit_CC_FirstName", new { @class = "field-validation-valid", data_valmsg_replace = "true" })
    </div>
</div>
<div class="cxo-paymentForms-creditCard-submit right">
   @Html.Hidden("Edit_CC_PaymentID")
   @Html.Hidden("Edit_CC_Brand")
   <button class="btn btn-default btn-lg mobile" type="button" onclick="return editPayment_cancel()">Cancel</button>
    
   <button class="btn checkout pull-right mobile" type="button" onclick="return submit_eCC()">Save</button>
</div>
submit_eCC is just a $ajax call to the controller to update the database, and has nothing to do with validation.
editPayment_cancel just clears the form and hides the form module.
Since I'm using $ajax, I set the Submit Form Handler to false to not submit a post back of the form.

And then wrote the script and called it. This example reflects the whole module, and would take too much time to condense
function load_eCC_validate() {

    var $cC_form                    = $("#Edit_CreditCard"),
        $cC_location                = $("#Edit_CC_LocationName"),
        $cC_fName                   = $("#Edit_CC_FirstName"),
        $cC_lName                   = $("#Edit_CC_LastName"),
        $cC_code                    = $("#Edit_CC_Code"),
        $cC_phone                   = $("#Edit_CC_Phone");
        $bA_streetAddress1          = $("#Edit_CC_StreetAddress1"),
        $bA_city                    = $("#Edit_CC_City"),
        $bA_stateCode               = $("#Edit_CC_StateCode"),
        $bA_postalCode              = $("#Edit_CC_PostalCode"),
        $bA_countryCode             = $("#Edit_CC_CountryCode");

    $cC_form.validate({<br />
        errorClass: 'form-control input-validation-error',
        validClass: 'form-control',
        errorElement: 'span',
        success: "valid",
        rules: {
            "Edit_CC_LocationName": {
                required: true
            },
            "Edit_CC_FirstName": {
                required: true
            },
            "Edit_CC_LastName": {
                required: true
            },
            "Edit_CC_ExpMonth": {
                required: true,
                valueNotEquals: ""
            },
            "Edit_CC_ExpYear": {
                required: true,
                valueNotEquals: ""
            },
            "#Edit_CC_Code": {
                required: true
            },
            "Edit_CC_Phone": {
                required: true,
                phoneUS: true
            },
            "Edit_CC_StreetAddress1": {
                required: true
            },
            "Edit_CC_City": {
                required: true
            },
            "Edit_CC_StateCode": {
                required: true
            },
            "Edit_CC_PostalCode": {
                required: true,
                zipcodeUS: true
            },
            "Edit_CC_CountryCode": {
                required: true
            }
        },
        messages: {
            "Edit_CC_LocationName":         "Unique name is required",
            "Edit_CC_FirstName":            "Card first name required",
            "Edit_CC_LastName":             "Card last name required",
            "Edit_CC_Code":                 "Card Security code required",
            "Edit_CC_ExpMonth":             "Card exp month required",
            "Edit_CC_ExpYear":              "Card exp year required",
            "Edit_CC_Phone":                "Phone number required",
            "Edit_CC_StreetAddress1":       "Billing street address required",
            "Edit_CC_City":                 "Billing city required",
            "Edit_CC_StateCode":            "Please select your state",
            "Edit_CC_PostalCode":           "Postal/zip code required",
            "Edit_CC_CountryCode":          "Please select your country"
        },
        submitHandler: function (form) {
            return false;<br />
        },
        invalidHandler: function (event, validator) {
            var errors = validator.numberOfInvalids();<br />
        },
        errorPlacement: function (error, element) {
            $(element).parent().next('span').html(error);
        }
    });

}

This works exactly like assigning required to the model, only I didn't assign required to the model.
Hope this makes sense to you, can't really explain it in more detail. But the HTML I posted is exactly what is needed to make it work.

Note, you may be able to disable validation using jquery by changing one of the attr in the validator. You have to look at the HTML that is generated to see which attr to change in the elements.
21st Century Globalism has become Socialism on a planetary scale, in which the unequal treaties of the past have come back into play.

AnswerRe: How to bypass fields that have required validation to go to next page Pin
bVagadishnu8-Dec-16 8:24
bVagadishnu8-Dec-16 8:24 
GeneralRe: How to bypass fields that have required validation to go to next page Pin
Bootzilla338-Dec-16 17:02
Bootzilla338-Dec-16 17:02 
AnswerRe: How to bypass fields that have required validation to go to next page Pin
Richard Deeming9-Dec-16 2:42
mveRichard Deeming9-Dec-16 2:42 
QuestionCall JavaScript function from c# code in cshtml Pin
sunsher7-Dec-16 19:56
sunsher7-Dec-16 19:56 
AnswerRe: Call JavaScript function from c# code in cshtml Pin
F-ES Sitecore8-Dec-16 0:40
professionalF-ES Sitecore8-Dec-16 0:40 
GeneralRe: Call JavaScript function from c# code in cshtml Pin
sunsher8-Dec-16 10:47
sunsher8-Dec-16 10:47 
GeneralRe: Call JavaScript function from c# code in cshtml Pin
F-ES Sitecore8-Dec-16 22:29
professionalF-ES Sitecore8-Dec-16 22:29 
Questionnpm install is not installing and erroring continuosly Pin
indian1437-Dec-16 10:49
indian1437-Dec-16 10:49 
QuestionEdit not working Pin
sunsher7-Dec-16 0:57
sunsher7-Dec-16 0:57 
AnswerRe: Edit not working Pin
Vincent Maverick Durano7-Dec-16 2:11
professionalVincent Maverick Durano7-Dec-16 2:11 
AnswerRe: Edit not working Pin
Richard Deeming7-Dec-16 2:13
mveRichard Deeming7-Dec-16 2:13 
AnswerRe: Edit not working Pin
jkirkerx7-Dec-16 8:38
professionaljkirkerx7-Dec-16 8:38 
QuestionAngularJS 2.0 with MVVM and C# Pin
indian1436-Dec-16 14:00
indian1436-Dec-16 14:00 
AnswerRe: AngularJS 2.0 with MVVM and C# Pin
Vincent Maverick Durano7-Dec-16 2:12
professionalVincent Maverick Durano7-Dec-16 2:12 
GeneralRe: AngularJS 2.0 with MVVM and C# Pin
indian1437-Dec-16 11:07
indian1437-Dec-16 11:07 
GeneralRe: AngularJS 2.0 with MVVM and C# Pin
Vincent Maverick Durano8-Dec-16 1:24
professionalVincent Maverick Durano8-Dec-16 1:24 
GeneralRe: AngularJS 2.0 with MVVM and C# Pin
indian1438-Dec-16 6:38
indian1438-Dec-16 6:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.