Partial view in another partial view validation doesn't work and it hits controller action method twice.

Hello Friends,

I have a partial view in that partial view i have another partial view with create ,edit buttons when i click on create or edit button it hits the controller action twice and validation doesn’t work i am using bootstrap mvc even i am using validate.js and
validateobstrusive.js but validation is not working. i think js files are overridden. I am displaying create and edit partial view in popup. 

Hi,

Make sure the pop up gets loaded with all require .JS files, right click , -> click view source then find out the .js files loaded or not, even you can use IE toolbar to find out the loaded file

Djack007

when i click on create or edit button it hits the controller action twice

I suspect on the button click you are doing a post or get to fetch the partial view and then using JQuery library which does another call to the server to show it in popup. Please post code so that we can understand how you are doing this

Djack007

validation doesn’t work

For popups sometimes you need to manually invoke the validation using validate plugin after the popup gets loaded.

I have a view in that view i am loading a partial view.

  @Html.Partial("ViewAddress", item)

in the viewAddress partial view i have edit and create htmlhelper

@Html.ActionLink("Create", "CreateAddress", "Entity", routeValues: new { id = Model.AddressID },
htmlAttributes: new { data_modal = "", @class = "btn btn-danger pull-right" }

due to bubbling it hits the controller twice and validation doesnt work…

Could you show your code(partial views and actions)Smile

Leave a Reply