Solved

Problem in validation control

Posted on 2009-05-18
8
209 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

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…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

912 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

21 Experts available now in Live!

Get 1:1 Help Now