views:

133

answers:

1

Does this <% Html.EnableClientValidation(); %> really enable client validation that validation without page refresh or not?

The thing is that it is doing a page refresh while returning formviewmodal ,it is working fine when using modal ? So how will i make it work using formviewmodal

here is the code of the controller returning FormViewModel

public class OrganizationGroupFormViewModel
{      
    public OrganizationGroup OrganizationGroups { get; set; }
    public OrganizationGroupFormViewModel() { }

    public OrganizationGroupFormViewModel(OrganizationGroup OrganizationG)
    {
        OrganizationGroups = OrganizationG; 
    }
}

public class OrganizationGroupsController : Controller
{
    public ActionResult Create()
    {       
        OrganizationGroup OrgGroup = new OrganizationGroup
        {
            int_CreatedBy = Authorization.UserID,
            dtm_CreatedDate = DateTime.Now
        };
        return View(new OrganizationGroupFormViewModel(OrgGroup));     
    }

    [HttpPost]
    public ActionResult Create(OrganizationGroup OrgGroup)
    {
        try
        {
          if (ModelState.IsValid)
           {
             OrgGroup.int_CreatedBy = Authorization.UserID;
             OrgGroup.dtm_CreatedDate = DateTime.Now;

             OrganizationGroupRepository.Add(OrgGroup);
             OrganizationGroupRepository.Save();

             return View(new OrganizationGroupFormViewModel(OrgGroup));
          }
          else
              return View(new OrganizationGroupFormViewModel(OrgGroup));
        }
        catch
        {
            return View(new OrganizationGroupFormViewModel(OrgGroup));
        }
    }
A: 

Yes, this helper method adds the appropriate javascript to the page in order to enable client validation. You will need to include the proper js scripts based on the framework you are using. Take a look at this blog post.

Darin Dimitrov
will it work appropiately if we return FormViewModel from the controller?
mazhar kaunain baig
What are those partial views containing? Please be more specific, describe your scenario, provide some sample code.
Darin Dimitrov