Solved

Problem in validation control

Posted on 2009-05-18
8
234 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
Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

691 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