I have a class which inherits from the TextBox class and I am creating a
requiredfield validator for this input control at runtime. Client side
validation seems to work fine, but when I force server side validation,
nothing happens, it simply posts the form and doesn't display the error
message. I think this might have to do with Viewstate stuff, and also, the
fact that it creates the new control all over again (in the class def.),
when the form is being submitted.
Any ideas?
Here's a simplified example (the control class definition) of what I am
trying to do:
// --- Required Field Textbox
public class Required : TextBox
{
protected RequiredFieldValidator reqCtl;
public string InvalidMessage;
protected override void OnPreRender(System.EventArgs e) {
reqCtl = new RequiredFieldValidator();
reqCtl.ControlToValidate = this.ID;
reqCtl.ErrorMessage = this.InvalidMessage;
//reqCtl.EnableClientScript = false;
//this.Parent.Controls.Add(reqCtl);
Controls.Add(reqCtl);
}
protected override void Render(HtmlTextWriter w)
{
base.Render(w);
reqCtl.RenderControl(w);
}
}
//--
Any ideas of how to get server side validation to work in this example, are
welcome.
Thanks!
Wim
HTH,
Daniel
"Wim Hollebrandse" <wim.hollebrandseATvi.net> wrote in message
news:utRxFxfuBHA.1608@tkmsftngp04...
Thanks!
Wim
"Daniel Cazzulino" <d_k...@yahoo.com> wrote in message
news:urZDW$vuBHA.2324@tkmsftngp02...
OnInit
-- LoadViewState
---- LoadPostData
------ OnLoad
-------- RaisePostDataChangedEvent
---------- RaisePostBackEvent
------------ OnPreRender
-------------- SaveViewState
---------------- Render
------------------ Dispose
Daniel
"Wim Hollebrandse" <wim.hollebrandseATvi.net> wrote in message
news:OyVRuGwuBHA.2280@tkmsftngp05...
Thanks,
Wim
"Daniel Cazzulino" <d_k...@yahoo.com> wrote in message
news:O3ILqZwuBHA.1860@tkmsftngp04...
Thanks
_
Muds.
Where Text_Box_Test is the ID of control to validate.
I hope this code helps you.
Atte. Elmer Carías
El Salvador
elmer_...@hotmail.com
<mudasi...@gmail.com> wrote in message
news:1103219827....@z14g2000cwz.googlegroups.com...