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.
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.
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 = "*";
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...
If i remove that line of code then if i entered the wrong values.....it is displaying "This field is required" for every field.But i want to display diff for diff fields.How to do that? Any idea?????????
You have access to all the controls in the form in the XForm_ControlsCreated method. You can spin the controls and do it there.
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?