CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 8/5/2005 3:00:12 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 0 Views: 41 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
1 Items, 1 Pages 1 |< << Go >> >|
Spyder94
Asp.Net User
Disabling Validation in a Custom Control8/5/2005 3:00:12 PM

0/0

I've created a custom control that works perfectly in every way except that it causes page validation to fire and I don't want it to.  I have not been able to figure out how to make this control not cause validation.

The control derives from Control and implements the IPostBackDataHandler and IValidator interfaces.  Initially, the Render method writes a textbox and a button to the output stream like so:

            StringBuilder sb = new StringBuilder();

            // textbox
            sb.Append("<input id=\"");
            sb.Append(this.UniqueID);
            sb.Append("_txtSearch");
            sb.Append("\" ");
            sb.Append("name=\"");
            sb.Append(this.UniqueID);
            sb.Append(":txtSearch");
            sb.Append("\" ");
            sb.Append("type=\"text\" ");
            sb.Append("onKeyDown=\"return catchEnterKey(window.event,'");
            sb.Append(this.UniqueID);
            sb.Append(":btnSearch');\"");

            if (this.ReadOnly)
            {
                sb.Append(" disabled=\"disabled\"");
            }

            sb.Append(">");

            // button
            sb.Append("<input ");
            sb.Append("type=\"submit\" ");
            sb.Append("name=\"");
            sb.Append(this.UniqueID);
            sb.Append("\" ");
            sb.Append("value=\"Bill-To\" ");
            sb.Append("id=\"");
            sb.Append(this.ClientID);
            sb.Append("\" ");
           
            sb.Append("class=\"button_default\"");
            if (this.ReadOnly)
            {
                sb.Append(" disabled=\"disabled\"");
            }
            sb.Append(">");
           
            return sb.ToString();

When the user enters text in the textbox and then clicks the button, the control catches the postback, and using the text does a db query and then the Render method outputs a dropdownlist with the query results in it.  All this works with no problems.  The issue being when the user clicks the button and postback occurs page validation is occuring.  So if I put my custom control in the middle of a form then the user is being told they have to put values in fields they haven't gotten to yet.

What I believe is happening is that on postback the framework sees that an "input type=submit" caused the postback. It then looks in the control collection for the control with the same id as the input that caused the postback.  Then it checks the CausesValidation of that control and calls Page.Validate if it's set to true OR if it doesn't find the control (since the default for CausesValidation is True).

As you can see from the code above the button is being rendered with the same id as the control itself so that the page will check the controls CausesValidation property.  Unfortunately this doesn't seem to work.  I've tried dozens of different methods and I'm at a total loss.  Can someone PLEASE help with this?

Thanks

1 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
ASP.NET Unleashed: unleashed Authors: Stephen Walther, Pages: 1488, Published: 2003
Pro ASP.NET 2.0 in VB 2005: special edition. Authors: Laurence Moroney, Matthew MacDonald, Pages: 1360, Published: 2006
MCAD/MCSD Training Guide (70-315): Developing and Implementing Web Applications with Visual C# and Visual Studio. NET Authors: Amit Kalani, Pages: 1200, Published: 2002
Pro .NET 2.0 Windows Forms and Custom Controls in C#: From Professional to Expert Authors: Matthew MacDonald, Pages: 1037, Published: 2005
MCAD Developing and Implementing Web Applications with Microsoft Visual C#(TM) . NET and Microsoft Visual Studio(R) . NET Exam Cram 2 (Exam Cram 70-315): Exam Cram 2, McAd Exam 70-315 Authors: Kirk Hausman, Amit Kalani, Ed Tittel, Pages: 600, Published: 2003
Sams Teach Yourself ASP.NET in 21 Days Authors: Chris Payne, Pages: 1104, Published: 2002
Inside Server-based Applications Authors: Douglas J. Reilly, Pages: 614, Published: 1999
Mastering Web Development with Microsoft Visual Studio 2005 Authors: John Paul Mueller, Pages: 822, Published: 2005
Essential ASP. NET with Examples in C#: With Examples in C# Authors: Fritz Onion, Pages: 393, Published: 2003
Pro ASP.NET 2.0 in C# 2005 Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1255, Published: 2005

Web:
ASP.NET: Selectively Enable Form Validation When Using ASP.NET Web ... The next step was to set up a property to accept a list of form validation controls that I wanted the custom control to disable. ...
Disabling validation in ASP.NET - Thea Burger's Blog Disabling validation in ASP.NET. The built in validation controls of ASP. ... how the validation process works and also shows an example of a custom control ...
InformIT: Performing Form Validation with Validation Controls ... You can use the Validation controls in ASP.NET to perform very different types of ... Custom Validation: The CustomValidator Control; Disabling Validation ...
ASP.NET QuickStart Tutorials To disable client-side validation, set the page's ClientTarget property to ... Performing Custom Validation. The CustomValidator server control calls a ...
jQuery Validation plugin: disable validation for specified submit ... How do you circumvent validation with specified submit controls (in other words, ... I would prefer to not have to create custom methods duplicating ...
InformIT: Performing Form Validation with Validation Controls ... Performing Custom Validation: The CustomValidator Control. The Validation controls included with ASP.NET enable you to handle a wide range of validation ...
book asp.net unleashed (2nd ed.), other web dedicated languages ... Performing Custom Validation: The CustomValidator Control. Validating Credit Card Numbers. Disabling Validation. Summary. 4. Advanced Control Programming. ...
Microsoft ASP.NET QuickStarts Tutorial To disable client-side validation, set the page's ClientTarget property to ... The CustomValidator control lets the user define custom validation criteria. ...
Disable Button On PostBack (ASP.NET) - also works with validation ... I want to preform Client-side validation and, if successfull, disable the button and postback. ... However, it did not work in a custom control (ascx). ...
K. Scott Allen : ASP.NET Event Validation and “Invalid Callback Or ... However, if we create a custom control and leave off the SupportsEventValidation attribute, we’ll effectively disable event validation for instances of that ...




Search This Site:










how do i make skins for dnn and make a 'skin-switcher'?

how to load and display pdf folders in a tree view

updated from win2k to xp -2147467259 (0x80004005) is all i get

exception handling

delete/sort threads in discussions module

access denied

by clicking a linkbutton, a pdf file should be downloaded.....

profile property collection

login using database

missing table in access scripts?

membership provider sql 2000 does not have a test in wat

need help with solpartmenu

defining theme/skin file for nested - css class and relative elements.

what's the difference between vs2003 and vs2005?

windows authentication with custom roles

membership.createuser() in sql clr

visual studio 2005

error - problem solved...

rainbow or dotnetnuke?

beta 1 to beta 2

file listing from a unc path

showing more details about circular reference error

almost working... i think i need help with connection string.

dnn & ssl (again)

i need help!

findcontrol not working within a content page

i have a warning in the build process.

need urgent help:modules are currently unavailable

serveritemclick not fireing when multipage/tabstrip present

getting applicationurl within scheduled task

 
All Times Are GMT