SaaS CMS has officially launched! Learn more now.

Why is the XForm's inline error message always an asterisk?


I've been trying to get the XForm's inline error message to be something other than an asterisk (star), but can't.

I've reflected through the EPiServer.XForms assembly, and found this code in the CreateRequiredValidator method of the XFormControl.

validator.ErrorMessage = XForm.TranslateResource(this, "/xform/requiredfield/summaryerrormessage");
validator.Text = XForm.TranslateResource(this, "/xform/requiredfield/inlineerrormessage");

I've gone through the languageEN.xml file and found this:

        <inlineerrormessage>This field is required</inlineerrormessage>
        <summaryerrormessage>You haven't specified all required fields</summaryerrormessage>

This would seem to indicate that the inline error message will be "This field is required."  Yet it never is -- it's always just an asterisk.  The summary error message is correct, but somewhere after the code I quoted above, the Text property of the validator is set to "*".

I've attached to the PreRender method and done this:

validatorControl.Text = validatorControl.ErrorMessage;

But this isn't great, because what if I want the inline text and summary text to be different?

Any ideas where this value could be set, and how to fix it?

Alterantely, in the PreRender event, I thought about manually setting the Text property to the value in the languageEN.xml file (so, doing manually what the system doesn't seem to want to do automatically).  However, the XForm.TranslateResource method is internal, so I can't call it from outside the assembly.


Sep 23, 2010 7:25

Well, I'm officially stumped.  I've dis-assembled the entire EPiServer.XForms assembly.  I can see where the validator is created, and the Text property is set to the value out of the lang file.  All is as it should be.

However, somewhere between then and when the thing renders, it gets changed to an asterisk.  I cannot find where or why this happens.

Sep 23, 2010 16:04

In the global ASAX file, they set it there by default.

public void XForm_ControlsCreated(object sender, EventArgs e)
            XFormControl formControl = (XFormControl)sender;
            //We set the inline error validation text to "*" as we use a
            //validation summary in the master page to display the detailed error message.
            foreach (Control control in formControl.Controls)
                if (control is BaseValidator)
                    ((BaseValidator)control).Text = "*";
    Just remove the ((BaseValidator)control).Text="*";
this will remove the * and display the message.
Sep 23, 2010 18:42

I was protoyping this in the default PublicTemplates project, which is why I didn't realize there was a bunch of the stuff in the global.asax to support this particular demo site.

If you listen closely, you can hear me weeping softly...

Sep 23, 2010 18:56


If i remove that line of code then if i entered the wrong is displaying "This field is required" for every field.But i want to display diff for diff fields.How to do that? Any idea?????????

Jul 08, 2011 14:31

Hey Murali,

You have access to all the controls in the form in the XForm_ControlsCreated method.  You can spin the controls and do it there.

Jul 08, 2011 14:42

Hi Joshua,

yes.But that method is in Global.asax file.Actually what i want to do is......i want to display the value entered by the user in textbox.But global.asax not allowing to write the Response method.Then how can i achieve this?

Jul 08, 2011 15:18
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.