This is a migrated thread and some comments may be shown as answers.

[Solved] Client Validation in LoadFromContent

5 Answers 51 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ivan
Top achievements
Rank 1
Ivan asked on 08 Feb 2012, 02:26 PM
Is it possible to validate on client, input in form which is loaded via ajax call.

5 Answers, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 08 Feb 2012, 06:26 PM
Hello Ivan,

 I suggest using jquery.validator.unobtrusive.parse method to achieve your goal. There is a sample project for common validation problems in our code library.

I hope this information helps. Please let me know if I can assist you any further.

Regards,
Alexander Valchev
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Ivan
Top achievements
Rank 1
answered on 09 Feb 2012, 11:20 AM
I tried with jquery.validator.unobtrusive.parse butt with no results.

Try to put <form> tag around tabstrip, and you will see, or just check attached solution.
0
Alexander Valchev
Telerik team
answered on 09 Feb 2012, 02:31 PM
Hi Ivan,

 <form> tag should not be wrapping the tabstrip, but the form's elements themselves.

@model User
 
    @*@Html.EditorForModel()*@
    @using (Html.BeginForm())
    {
            @Html.TextBoxFor(model => model.UserName, new { style = "width:200px;" })
            @Html.ValidationMessageFor(model => model.UserName)
            <br />
            @Html.TextBoxFor(model => model.Email, new { style = "width:200px;" })
            @Html.ValidationMessageFor(model => model.Email)
            <input type="submit" value="Save" />
    }

I edited your project. Please check the attachment.

Greetings,
Alexander Valchev
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Ivan
Top achievements
Rank 1
answered on 09 Feb 2012, 02:38 PM
Butt I want exactly tabstrip to be placed inside of  <form> tag .
Because I have several tabs and all of them should reside in one <form> tag for later submission to server.

0
Accepted
Alexander Valchev
Telerik team
answered on 13 Feb 2012, 01:46 PM
Hello Ivan,

It is not possible to validate the form items loaded via Ajax in your case, because:
  • If there is no form in the partial view so validation attributes of input fields will not be rendered.
  • If there is a form, it will be possible to validate and submit the data only within the current tab. However that will not work in Chrome, because the inner form will not be added to the DOM tree.
In addition when you use LoadContentFrom method, input fields will not be added before their tab is selected. In other words, fields that are not loaded will not be validated or submitted.

I suggest you to load form fields on the server using the Content method. For example:
.Items(items =>
{
    items.Add().Text("Insert in Ajax Loaded Tab")
    .Content(Html.Action("InsertUser").ToHtmlString());
})

This way all the problems above will be avoided.

 Greetings,
Alexander Valchev
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
TabStrip
Asked by
Ivan
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Ivan
Top achievements
Rank 1
Share this question
or