Adding custom error message to ValidationSummary without validators
Validators are a great thing in the ASP.Net world (as well as the .Net WinForms world...), but sometimes they don't suffice. For example, if you want to validate something not related to a control on the page or something very complex you can't achieve even with the custom validators, you may want a particular solution like this one.
First approach : using the CustomValidator
With this approach you simply have to do the following piece of code when you want to add a custom message to your validator :
CustomValidator val = new CustomValidator();
val.IsValid = false;
val.ErrorMessage = "Custom error message to add to the ValidationSummary";
this.Page.Validators.Add(val);
This is a cool, clean and simple way to add custom error messages to the ValidationSummary.
Second approach : creating a validator by implementing IValidator
The .Net framework allows you to create very custom validator by implementing the IValidator interface. So you create the validator and then use the same technique I've just showed you before, just like this :
public class ValidationError : IValidator
{
private ValidationError(
string message)
{
this.ErrorMessage = message;
}
public void Validate()
{
this.IsValid =
false;
}
}
this.Page.Validators.Add(
new ValidationError(
"Your custom error message"));
Personnaly I prefer this one because you are completely custom and you can add messages in a single line of code.
Culture ID 2155 (0x086B) is not a supported culture
I recently came across a VERY annoying problem on my personnal (this one) BlogEngine.Net blog.
What happened is that I installed some Windows Updates (a bunch) on my Windows Server 2003 server and then, every time I accessed an article of this blog I received this error message : Culture ID 2155 (0x086B) is not a supported culture. What a real annoying problem !!
I don't know the exact reason but what I know is that cultures are OS specific, so the Windows Update is the cause... it's not related to the .Net Framework so don't waste your time trying to reinstall the framework, it will not work.
The Solution...
Resintall the Service Pack 2 for your Windows Server 2003.