i am trying to get mvc2 client validation working with a jquery dialog, i have pretty much been using the mvc music store example at http://www.asp.net/mvc. if i go to http://localhost/Build/Edit/11, client validation
works, but it will not work in the jquery dialog. any ideas?
ViewActive.aspx - main page with a link to popup a form
...
function showModalEdit(id) {
var $loading = $('<img src="<%= Url.Content("~/Content/Images/ui-anim_basic_16x16.gif") %>" alt="loading"/>');
var $dialogEdit = $('<div id="dialogEdit"></div>').append($loading.clone());
$dialogEdit.find(':submit').hide();
$dialogEdit.dialog({
height: 768,
width: 1024,
autoOpen: false,
title: "Modify Build",
modal: true,
close: function () {
$dialogEdit.remove();
},
buttons: {
Cancel: function () {
$(this).dialog('close');
}
}
});
$.get('<%= Url.Content("~/Build/Edit/") %>' + id, function (data) {
You only need to replace alert with jquery dialog or custom dialog
"And whoever is removed away from the Fire and admitted to Paradise, he indeed is successful." (The Holy Quran)
Excellent Windows VPS Hosting Imran Baloch MVP, MVB, MCP, MCTS, MCPD
i did not add the dialog box yet, but the alert box is not showing up if it is in the dialog. it does show up if i go to
http://localhost:38872/Build/Edit/11.
i did not add the dialog box yet, but the alert box is not showing up if it is in the dialog. it does show up if i go to
http://localhost:38872/Build/Edit/11.
Not getting what are you saying
"And whoever is removed away from the Fire and admitted to Paradise, he indeed is successful." (The Holy Quran)
Excellent Windows VPS Hosting Imran Baloch MVP, MVB, MCP, MCTS, MCPD
simps33
0 Points
2 Posts
MVC2 client validation with jquery dialog
Sep 23, 2010 10:16 PM|LINK
i am trying to get mvc2 client validation working with a jquery dialog, i have pretty much been using the mvc music store example at http://www.asp.net/mvc. if i go to http://localhost/Build/Edit/11, client validation works, but it will not work in the jquery dialog. any ideas?
ViewActive.aspx - main page with a link to popup a form
...
function showModalEdit(id) {
var $loading = $('<img src="<%= Url.Content("~/Content/Images/ui-anim_basic_16x16.gif") %>" alt="loading"/>');
var $dialogEdit = $('<div id="dialogEdit"></div>').append($loading.clone());
$dialogEdit.find(':submit').hide();
$dialogEdit.dialog({
height: 768,
width: 1024,
autoOpen: false,
title: "Modify Build",
modal: true,
close: function () {
$dialogEdit.remove();
},
buttons: {
Cancel: function () {
$(this).dialog('close');
}
}
});
$.get('<%= Url.Content("~/Build/Edit/") %>' + id, function (data) {
$dialogEdit.html(data);
});
$dialogEdit.dialog('open');
//return false;
}
...
<a href="javascript:showModalEdit(<%:build.id %>)"><span>Modify</span></a>
...
Edit.aspx -
<div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"><script src="/Scripts/MicrosoftAjax.js" type="text/javascript"></script></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"><script src="/Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"><script src="/Scripts/MicrosoftMvcValidation.js" type="text/javascript"></script></div><script src="/Scripts/MicrosoftAjax.js" type="text/javascript"></script>
<script src="/Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script>
<script src="/Scripts/MicrosoftMvcValidation.js" type="text/javascript"></script>
...
<% Html.EnableClientValidation(); %>
<% using (Html.BeginForm("Edit", "Build"))
{%>
<fieldset>
<legend>Create Album</legend>
<%: Html.ValidationSummary(true) %>
<%: Html.EditorFor(model => model.Build, new { Releases = Model.Releases, ReoccuringBuild = Model.ReoccuringBuild })%>
<%: Html.EditorFor(model => model.ReoccuringBuild)%>
<p>
<input type="submit" value="Save" />
</p>
</fieldset>
<% } %>
Build.cs - model
...
[Required(ErrorMessage = "Enter a Comment")]
public object Comment { get; set; }
...
Build.ascx - editor template
...
<%: Html.LabelFor(model => model.Comment)%>
<%: Html.TextAreaFor(model => model.Comment)%>
<%: Html.ValidationMessageFor(model => model.Comment)%>
...
imran_ku07
All-Star
45815 Points
7698 Posts
MVP
Re: MVC2 client validation with jquery dialog
Sep 24, 2010 03:43 AM|LINK
See, http://forums.asp.net/t/1597326.aspx
You only need to replace alert with jquery dialog or custom dialog
Excellent Windows VPS Hosting
Imran Baloch MVP, MVB, MCP, MCTS, MCPD
simps33
0 Points
2 Posts
Re: MVC2 client validation with jquery dialog
Sep 24, 2010 11:11 PM|LINK
i did not add the dialog box yet, but the alert box is not showing up if it is in the dialog. it does show up if i go to http://localhost:38872/Build/Edit/11.
imran_ku07
All-Star
45815 Points
7698 Posts
MVP
Re: MVC2 client validation with jquery dialog
Sep 25, 2010 02:19 AM|LINK
Not getting what are you saying
Excellent Windows VPS Hosting
Imran Baloch MVP, MVB, MCP, MCTS, MCPD
Bober Song -...
All-Star
34686 Points
2167 Posts
Re: MVC2 client validation with jquery dialog
Sep 27, 2010 03:15 AM|LINK
Hi simps33 ,
You need to reference the JQuery library and JQuery dialog plugin file.
http://jqueryui.com/demos/dialog/
I hope it is helpful to you.
If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework