|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Validator inside WebControlWhy can't i create a validatorControl as a child of the control to validate? It doesn't give any errors, but it just won't work (it's not validating). The reason why i want this is that i'm creating a repository of WebControls extended/inherited with my own code for repetative use. For example, i have a: Class CreationDate inherits TextBox I offcourse want a validator to check is really a date was entered into the textbox. I use this custom WebControl on multiple pages. In those pages i only want to code: <myRepository:CreationDate runat="server" /> I do not want to code a <asp:rangeValidator> on every page. That should be handled by the <myRepository:CreationDate> tag itself. I've tried: -------------------- Public Class CreationDate inherits TextBox Sub new dim validator as new RangeValidator 'setting validator properties me.controls.add(validator) End Sub End Class -------------------- This just doesn't work. no errors, but also no validation. So i tried: -------------------- Public Class CreationDate inherits TextBox Sub onInit/onLoad dim validator as new RangeValidator 'setting validator properties me.page.controls.add(validator) End Sub End Class -------------------- This gave an error that i'm not allowed to add controls to the controll collection (of the page) while in onInit/onLoad/onPreRender mode. The page is currently in PreRender mode (in a non postback situation) when this object goes through it's events. I should mention that this WebControl is in a (CompiledBindable)Template which is instantiated in the CreateChildControls of it's container. (but this CreateChildControls is created in the onLoad event i believe). I've also tried. -------------------- me.parent.controls.add(validator) -------------------- But this also didn't work. So could anyone please tell me how i can add a validator from within the control(ToValidate) itself. I'm just don't know anymore (and sometime can get really frustrated on "the microsoft way" of doing things) I hope somebody has a solution for me, otherwise this repository is quite doomed. Regards, Sam "Sam" <n***@verveeltzich.com> wrote in message This is a VB "classic" newsgroup. Questions about VB.NET (including VB 2005,news:newscache$surqsi$6yu$1@news.easynet.nl... > Class CreationDate inherits TextBox which has dropped .NET from its name) are off-topic here. Please ask .NET questions in newsgroups with "dotnet" in their names. The *.vb.* groups are for VB6 and earlier. If you don't see the *.dotnet.* groups on your news server, connect directly to the Microsoft server: msnews.microsoft.com.
Other interesting topics
How to stop processing request in global.asax
remember me cookie in asp .net Problem compiling remote web in VS2005 WebPartManager: disable Personalization and still use WebPartManger.AddWebPart() What would be a good design for my application ASP:TableRow with dynamic design Asp.net And Firefox dynamic column/fields How to raise exception which automatically written to Application event log? Hirarchical View in GridView |
|||||||||||||||||||||||