MvcValidatorToolkit/Extensions/ViewPageExtensions.cs
/// <summary>
/// Renders the client script function to setup the client-side validation.
/// </summary>
Renders the client script function to setup the client-side validation.
Renders the client script function to setup the client - side validation .
public static void RenderValidationSetScripts(this ViewPage viewPage, bool addScriptTags)
		{
			ValidationSetAttribute[] attributes = (ValidationSetAttribute[])viewPage.GetType().GetCustomAttributes(typeof(ValidationSetAttribute), true);
			StringBuilder sb = new StringBuilder();
			sb.AppendLine();
			if(addScriptTags)
				sb.AppendLine("<script type=\"text/javascript\">");
			foreach(ValidationSetAttribute vsa in attributes)
			{
				NameValueCollection errorMessages = viewPage.ViewData[vsa.ValidationSet.GetType().Name + ".ErrorMessages"] as NameValueCollection;
				sb.Append(vsa.ValidationSet.CreateClientScript(errorMessages));
			}
			if(addScriptTags)
				sb.AppendLine("</script>");
			viewPage.Response.Write(sb.ToString());
		}
public static void RenderValidationSetScripts ( this ViewPage viewPage , bool addScriptTags ) { ValidationSetAttribute [ ] attributes = ( ValidationSetAttribute [ ] ) viewPage . GetType ( ) . GetCustomAttributes ( typeof ( ValidationSetAttribute ) , true ) ; StringBuilder sb = new StringBuilder ( ) ; sb . AppendLine ( ) ; if ( addScriptTags ) sb . AppendLine ( " \" \" " ) ; foreach ( ValidationSetAttribute vsa in attributes ) { NameValueCollection errorMessages = viewPage . ViewData [ vsa . ValidationSet . GetType ( ) . Name + " " ] as NameValueCollection ; sb . Append ( vsa . ValidationSet . CreateClientScript ( errorMessages ) ) ; } if ( addScriptTags ) sb . AppendLine ( " " ) ; viewPage . Response . Write ( sb . ToString ( ) ) ; }
Renders the client script function to setup the client-side validation.
Renders the client script function to setup the client - side validation .
// Get all defined validation sets for the derived view page class // Generate script files for each validation set
ViewPage
this
addScriptTags
bool