Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Problem in validation control

Posted on 2009-05-18
8
Medium Priority
?
247 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

604 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