Well something strange is happening when using a select list(<select>) in mvc 3 . For starters, i'm just using an MVC form with some labels and textboxes (labelFor and TextBoxFor) a model. On those properties I'm using dataannotations to client side validate
those properties. Everything works and validates fine until I use a select tag. Then the javascript validation breaks and the Firefox error console gives me this error "Error: val is undefined
Source File: http://myserver.homeip.net:5043/Assets/Scripts/Core/jquery.validate.min.js
Line: 20". So for some reason the jquery validation code breaks on a <select> tag. For the record I did nothing do anything special with the select tag, even if i write it like this " <select name="test"><option value="1">test</option></select> every javascript
code fails, even a simple alert('test') event. When I remove the <select> tag everything just works fine again. Also I'm not trying to validate the select tag it's just euh a <select> tag.
Is this a bug or am I missing something concerning the use of dropdownlists in MVC 3?
Well,
It seems that the jquery release 1.4.4.min.js generated the error when using a select tag in MVC 3. I changed the version of jquery to 1.6.1 and the problem was solved. It may seem obvious, but until now when you create a new mvc 3 project, microsoft automatically
refers to jquery 1.4.4. But apparently that files breaks on select tags.
Maybe its not a bug and I'm of track, but nevertheless 1.6.1 did not fail on select tags, so when you encounter this
anomaly
change the jquery version to the latest.
DriesM
Marked as answer by DriesM on Jun 11, 2011 08:35 PM
DriesM
Member
51 Points
105 Posts
MVC Bug ??
Jun 11, 2011 07:56 PM|LINK
Well something strange is happening when using a select list(<select>) in mvc 3 . For starters, i'm just using an MVC form with some labels and textboxes (labelFor and TextBoxFor) a model. On those properties I'm using dataannotations to client side validate those properties. Everything works and validates fine until I use a select tag. Then the javascript validation breaks and the Firefox error console gives me this error "Error: val is undefined
Source File: http://myserver.homeip.net:5043/Assets/Scripts/Core/jquery.validate.min.js
Line: 20". So for some reason the jquery validation code breaks on a <select> tag. For the record I did nothing do anything special with the select tag, even if i write it like this " <select name="test"><option value="1">test</option></select> every javascript code fails, even a simple alert('test') event. When I remove the <select> tag everything just works fine again. Also I'm not trying to validate the select tag it's just euh a <select> tag.
Is this a bug or am I missing something concerning the use of dropdownlists in MVC 3?
Thanks
DriesM
DriesM
Member
51 Points
105 Posts
Re: MVC Bug ??
Jun 11, 2011 08:27 PM|LINK
Well,
It seems that the jquery release 1.4.4.min.js generated the error when using a select tag in MVC 3. I changed the version of jquery to 1.6.1 and the problem was solved. It may seem obvious, but until now when you create a new mvc 3 project, microsoft automatically refers to jquery 1.4.4. But apparently that files breaks on select tags.
Maybe its not a bug and I'm of track, but nevertheless 1.6.1 did not fail on select tags, so when you encounter this anomaly change the jquery version to the latest.
DriesM