Hi,
I have a custom server control - a radio button list. It was written a while ago before we went down the composite control route and constructs itself through the Render method.
I now want to add a validation control to it. So, proceeded to do this from the CreateChildControls method.
The problem is this - when you set the "ControlToValidate" property ( i.e. to the ID of the radio button ) an exception is thrown due to the fact - I think - that the radio button has not yet been created.
So, I set up the control as normal in the CreateChildControls method but did not add it. I tried placing the following code at the end of the Render method:-
mybase.Render
controls.add(myvalidator)
This did not work i.e. did not render the validator. Tried the following:-
controls.add(myvalidator)
mybase.Render
First of all, the ID of the radio button list could not be found ( radio button not created?? ), then this strange error started to appear which seems to crop up from time to time : "script library webuivalidation.js could not be found" - even though it is definitely there.
Thus, tried adding a normal textbox instead of a validator and everything worked fine i.e. no message for the script library and the textbox rendered.
I'm swaying towards the solution of rewriting the construction of the radio button list in the CreateChildControls method ( remove the Render method completely ) so I know that I can access the ID property for the validation object.
Does anybody have any suggestions before I do rewrite? Is there absolutely no way that the CreateChildControls method can be suppressed from firing until the render method has fired, or any other way of correctly setting the ControlToValidate property of the validation object without the exception being thrown?
Cheers,
Glyn.
I have a custom server control - a radio button list. It was written a while ago before we went down the composite control route and constructs itself through the Render method.
I now want to add a validation control to it. So, proceeded to do this from the CreateChildControls method.
The problem is this - when you set the "ControlToValidate" property ( i.e. to the ID of the radio button ) an exception is thrown due to the fact - I think - that the radio button has not yet been created.
So, I set up the control as normal in the CreateChildControls method but did not add it. I tried placing the following code at the end of the Render method:-
mybase.Render
controls.add(myvalidator)
This did not work i.e. did not render the validator. Tried the following:-
controls.add(myvalidator)
mybase.Render
First of all, the ID of the radio button list could not be found ( radio button not created?? ), then this strange error started to appear which seems to crop up from time to time : "script library webuivalidation.js could not be found" - even though it is definitely there.
Thus, tried adding a normal textbox instead of a validator and everything worked fine i.e. no message for the script library and the textbox rendered.
I'm swaying towards the solution of rewriting the construction of the radio button list in the CreateChildControls method ( remove the Render method completely ) so I know that I can access the ID property for the validation object.
Does anybody have any suggestions before I do rewrite? Is there absolutely no way that the CreateChildControls method can be suppressed from firing until the render method has fired, or any other way of correctly setting the ControlToValidate property of the validation object without the exception being thrown?
Cheers,
Glyn.