Solved

Problem in validation control

Posted on 2009-05-18
8
215 Views
Last Modified: 2013-11-08
Hi

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;
}

Open in new window

0
Comment
Question by:KaranGupta
  • 5
  • 3
8 Comments
 
LVL 11

Expert Comment

by:Muhammad Ousama Ghazali
ID: 24418994
Dynamically created controls should be added from within the Page_Init event even on postbacks, otherwise there expected events would not fire.
Let me get back to you with a link to a recent discussion on EE on about the same matter.
0
 

Author Comment

by:KaranGupta
ID: 24419006
Can we add Page_Init event in web custom control
0
 
LVL 11

Expert Comment

by:Muhammad Ousama Ghazali
ID: 24419009
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 11

Expert Comment

by:Muhammad Ousama Ghazali
ID: 24419020
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.
0
 

Author Comment

by:KaranGupta
ID: 24419040
I have implemented in that way(code section)

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;
 
        }

Open in new window

0
 
LVL 11

Accepted Solution

by:
Muhammad Ousama Ghazali earned 500 total points
ID: 24419094
Try putting breakpoints on the Page_Init code. If it does not solve, go to Tools > Options > Debugging and check if a certain setting is prohibiting debugger to break in user/custom control.
One more thought, if you have placed this code in a separate DLL and only referencing this DLL in your active project withou Debug Symbols, you may have the problem with debugger.
0
 

Author Comment

by:KaranGupta
ID: 24419124
Hi

Debugging is enabled as I am able to get the control on Render() method
0
 
LVL 11

Expert Comment

by:Muhammad Ousama Ghazali
ID: 24419182
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.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question