Click here to Skip to main content
16,016,693 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
on dropdown change calling Ajax one partial view appending on one div

HTML
@Html.TextBox("ControlValue", null, new { @data_val = "true", @data_val_length = "max lenth valtn", @data_val_length_max = "10", @data_val_regex = "regex validntn error msg", @data_val_regex_pattern = "^[0-9]*$"})

@Html.ValidationMessage("ControlValue")


JavaScript
$.ajax({
                      type: 'POST',
                      headers: { 'VerificationToken': $("#forgeryToken").val() },
                      url: "@Url.Action("GetReportParameter")",
                      cache: false,
                      data: { rptID: $(this).val(), schID: 0, schType: $('#ddlSchType').val(), rptType: $("#ddlrptType").val() },
                      success: function (data) {

                              $('#divReportParameter').html(data);
                              $.validator.unobtrusive.parse("#frmScheduler");

                      }
                  })


this is how i am appending validation also

this validation is working with normal request means

if i am calling

@Html.Action("Actionname")

@Html.Partial("Actionname",Model)

validation is working

but in case of Ajax its not working

What I have tried:

normal request working but in case of Ajax its not working
Posted
Updated 14-Jul-16 1:42am
v2
Comments
John C Rayan 14-Jul-16 7:31am    
Do you get the posted values into GetReportParameter method?

1 solution

HTML
var form = $("#divReportParameter").closest("form");
                              form.removeData('validator');
                              form.removeData('unobtrusiveValidation');
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900