KaranGupta
asked on
Problem in validation control
Hi
I have created the validation summary control dynamically(see code section)
even if validation fails I am not able to see the validation
I have created the validation summary control dynamically(see code section)
even if validation fails I am not able to see the validation
ValidationSummary oValidationSummary = new ValidationSummary();
oValidationSummary.ID = "val";
oValidationSummary.DisplayMode = ValidationSummaryDisplayMode.BulletList;
oValidationSummary.EnableClientScript = true;
oValidationSummary.ShowSummary = true;
CustomValidator oCustomValidator = new CustomValidator();
oCustomValidator.ID = "cvName";
oCustomValidator.Visible = true;
oCustomValidator.ControlToValidate = ID;
oCustomValidator.Enabled = true;
oCustomValidator.ValidateEmptyText = true;
oCustomValidator.ErrorMessage = MTBErrorMessage;
oCustomValidator.ServerValidate += new ServerValidateEventHandler(oCustomValidator_ServerValidate);
void oCustomValidator_ServerValidate(object source, ServerValidateEventArgs args)
{
Validation oValidation = new Validation();
bool status = true;
status = oValidation.IsValid(MTBValidationType, Text);
args.IsValid = status;
}
ASKER
Can we add Page_Init event in web custom control
Here is the link I mentioned above: http://www.experts-exchang e.com/Web_ Developmen t/Web_Lang uages-Stan dards/ASP/ Q_24402249 .html
If you are asking about WebUserControl, then yeah surely you can add. And if you are Custom Web Server Controls, I think it should allow you to have this.
ASKER
I have implemented in that way(code section)
but the debugging control is not going on Page init
but the debugging control is not going on Page init
private void Page_Init(object sender, EventArgs e)
{
if (MTBErrorMessageControlType == MTBErrorMessageControl.VALIDATIONSUMMARY)
{
ValidationSummary oValidationSummary = new ValidationSummary();
oValidationSummary.ID = "val";
oValidationSummary.DisplayMode = ValidationSummaryDisplayMode.BulletList;
oValidationSummary.EnableClientScript = true;
oValidationSummary.ShowSummary = true;
CustomValidator oCustomValidator = new CustomValidator();
oCustomValidator.ID = "cvName";
oCustomValidator.Visible = true;
oCustomValidator.ControlToValidate = ID;
oCustomValidator.Enabled = true;
oCustomValidator.ValidateEmptyText = true;
oCustomValidator.ErrorMessage = MTBErrorMessage;
oCustomValidator.ServerValidate += new ServerValidateEventHandler(oCustomValidator_ServerValidate);
}
}
void oCustomValidator_ServerValidate(object source, ServerValidateEventArgs args)
{
Validation oValidation = new Validation();
bool status = true;
status = oValidation.IsValid(MTBValidationType, Text);
args.IsValid = status;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi
Debugging is enabled as I am able to get the control on Render() method
Debugging is enabled as I am able to get the control on Render() method
I just tested at my machine in VS2008 that the Page_Init on a WebUserControl is being debugged by the Debugger. Please look into the settings of VS2008 Debugger.
Let me get back to you with a link to a recent discussion on EE on about the same matter.