We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Dropdownlist - Unobstrusive validation

Thread ID:

Created:

Updated:

Platform:

Replies:

142028 Jan 15,2019 08:24 PM UTC Sep 13,2019 10:26 AM UTC ASP.NET Core - EJ 2 7
loading
Tags: Dropdown List
Daniel Duvoisin
Asked On January 15, 2019 08:24 PM UTC

Hi support,

I'm trying to use unobstrusive validation (model annotation) with dropdownlist, but it's not working.
Everything works with textbox.

How can I configure validation for dropdownlist controls?

Regards

Deepa Loganathan [Syncfusion]
Replied On January 16, 2019 12:41 PM UTC

Hi Daniel,  
 
Thanks for contacting Syncfusion support. 
 
We have created a simple test sample to test the unobtrusive validation of Dropdownlist with Data annotation and we can confirm that the Dropdownlist is rendering properly without any issues. Please find the below code sample. 
 
[cshtml] 
 
<form id="dropdownsform" method="post"> 
    <div class="form-group"> 
        <div> 
            <ejs-dropdownlist id="DropTitle" ejs-for="DropTitle" dataSource="@ViewBag.data" placeholder="Select a game" popupHeight="220px"> 
            </ejs-dropdownlist> 
            <span asp-validation-for="DropTitle" class="text-danger"></span> 
        </div> 
    </div> 
 
    <input type="submit" value="submit" class="e-control e-btn"/> 
</form> 
 
[cs] 
 
public IActionResult Index() 
        { 
            ViewBag.data = new string[] { "Badminton", "Basketball", "Cricket", "Football", "Golf", "Gymnastics", "Hockey", "Tennis" }; 
            return View(); 
        } 
 
public class Annotation 
    { 
        [Required(ErrorMessage = "DropDownList value is required")] 
        public string DropTitle { get; set; } 
 
} 
 
 
 
For your reference, we have attached the test sample in the below link.  
 
Sample:  
 
So, kindly check if the ID is mapped properly and if the issue still persists, get back to us with the below details.  
 
1.      Are you facing any script error? 
2.      Video of the issue 
3.      View and Model used in your application 
 
The details you provide would help us in further investigation of the issue and provide you a prompt solution at the earliest. 
 
Regards,  
Deepa L. 


Daniel Duvoisin
Replied On January 16, 2019 07:41 PM UTC

Hi Deepa,

Thank you for the answer, but i don't see the link (for the sample).
Another question, I can't find the nugets of version 16.4, can you help me?

Regards

Prince Oliver [Syncfusion]
Replied On January 17, 2019 10:48 AM UTC

Hi Daniel,   

Thank you for your update. 


You can find the NuGet packages for EJ2 ASP.NET Core from following package source. 

Syncfusion publishing the NuGet packages in nuget.org. Please find the Syncfusion NuGet packages v16.4 from below link.   
  
You can use the search option in Visual Studio NuGet package manager to install the required packages.   

Furthermore, Take a moment to look at the following KB document that is related to the issue: https://www.syncfusion.com/kb/9337/syncfusion-nuget-packages-updates-not-available-for-latest-version 

Please let us know if you need any further assistance on this. 

Regards, 
Prince 


Daniel Duvoisin
Replied On January 18, 2019 09:14 PM UTC

Hi Prince,

I have created a simple project to test the unobstrustive validation and i have reproduced the problem.
Please find my sample in attachment.

Regards

Attachment: syncfusionrequired_ec6fd32f.zip

Christopher Issac Sunder K [Syncfusion]
Replied On January 22, 2019 06:01 AM UTC

Hi Daniel, 

Thanks for the update. 

We have checked your shared sample. The cause of the problem is, you have used 16.4.0.42 version, but the data-annotation attribute in ASP.NET Core Tag helper support is provided in version 16.4.0.47. We suggest you upgrade the package to the latest version. We have updated the version in the provided sample and the validation is working fine. Please find the modified sample for your reference.  


Please check it and let us know if you have any concerns. 

Thanks, 
Christo 


Replied On September 12, 2019 01:29 PM UTC

This sample has a bug. The error message don't go away once we select a value

Ashokkumar Balasubramanian [Syncfusion]
Replied On September 13, 2019 10:26 AM UTC

Hi Daniel, 
 
We would like to inform you that our Dropdown List component server-side validation will begin after the form submission. We have checked this scenario in your provided sample, it’s works properly at our end.  
 
Also, if you want the Dropdown List component with dataSource on after form submission, we need to return the corresponding dataSource in server-side. Could you please check the below block and sample? 
 
public IActionResult PostExample(Annotation annotation) 
        { 
            if (!ModelState.IsValid) 
            { 
                ViewBag.data = new List<Test> { new Test { Id = 1, Name = "Name-1" }, new Test { Id = 2, Name = "Name-2" } }; 
                return View("index"); 
            } 
 
            return View("index"); 
 
        } 
 
Sample:  
 
 
Could you please check the sample and let us know, if you require any further assistance on this? 
 
Regards, 
Ashokkumar B. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;