Solved

Problem in validation control

Posted on 2009-05-18
8
202 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now