?
Solved

Problem in validation control

Posted on 2009-05-18
8
Medium Priority
?
241 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 2000 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

Command Line Tips and Tricks

The command line is a powerful tool at the disposal of every Linux user. Although Linux distros come with beautiful user interfaces, it's worthwhile to learn the command line because it allows you to do a number of things that you otherwise cannot do from the GUI.  

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

801 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