Great post, thank you for sharing your thoughts on this Stuart!
This helped me develop another approach that has worked for me. Just continuing to pay it forward here.
Any type of validator can be used in this approach. But all client scripting must be turned OFF on all validators and the ValidateEmptyText property set to true on all CustomValidators.
The RadWindow contains a simple div with unique ID. I use jQuery to copy the ValidationSummary here. For some reason the ValidationSummary does not show for me in the RadWindow. Probably due to the ContentTemplate, not sure.
<
telerik:RadWindowManager
ID
=
"ArMaintenanceRadWindowManager"
runat
=
"server"
>
<
Windows
>
<
telerik:RadWindow
ID
=
"ValidationWindow"
Title
=
"Validation Errors"
runat
=
"server"
Width
=
"400"
Height
=
"300"
CssClass
=
"modal-with-splitter"
KeepInScreenBounds
=
"true"
Behaviors
=
"Close,Move,Resize"
>
<
ContentTemplate
>
<
div
id
=
"ValidationSummary"
></
div
>
</
ContentTemplate
>
</
telerik:RadWindow
>
</
Windows
>
</
telerik:RadWindowManager
>
Then I use another Div to wrap the real ValidationSummary tag and hide it elsewhere on the page where it works more naturally.
<
div
id
=
"ValidationSummaryHidden"
style
=
"display:none;"
>
<
asp:ValidationSummary
runat
=
"server"
ID
=
"FormValidationSummary"
CssClass
=
"save-message-error"
DisplayMode
=
"BulletList"
ShowValidationErrors
=
"true"
ShowSummary
=
"true"
ShowMessageBox
=
"false"
EnableClientScript
=
"false"
/>
</
div
>
If validation fails in the save button event, then I call a javascript function that exists at the bottom of the page. I use the script manager because this is all likely going on inside an ajax panel of some sort.
protected
void
SaveButton_Click(
object
sender, EventArgs e)
{
if
(
this
.Page.IsValid)
{
// do good stuff.
}
else
{
// show validation error in RadWindow!
ScriptManager.RegisterClientScriptBlock(
this
.Page,
this
.GetType(),
"ShowValidationWindow"
,
"ShowValidationWindow();"
,
true
);
}
}
Here is the javascript using a little jQuery to copy the ValidationSummary to the RadWindow and show that window!
<
telerik:RadScriptBlock
runat
=
"server"
ID
=
"SicScriptBlock"
>
<
script
type
=
"text/javascript"
>
function ShowValidationWindow() {
$('#ValidationSummary').html($('#ValidationSummaryHidden').html());
var win = $find("<%= this.ValidationWindow.ClientID %>");
win.show();
}
</
script
>
</
telerik:RadScriptBlock
>