Clearing an Infragistics WebDateChooserThe infragistics webdatechooser is a very handy control for your website, easy to use and, as all infragistics controls, very configurable.
The only problem is when you filled in a value and want to empty the value, it retains the previously selected value. To really set the value to null, we can use its EditKeyUp event and a little javascript :
Change the control definition to (controlnames have been altered to protect the innocent) :
<igsch:webdatechooser id="wdcMyChooser" runat="server">
...
<clientsideevents editkeyup="webDateChooser_EditKeyUp">
<igsch:webdatechooser>
The name was kept generic, so that this function can be used for more than one webdatechooser on a page (or in an external javascript file or … )
Now all we have to do is add the Javascript function :
function webDateChooser_EditKeyUp(oDateChooser, keyCode, oEvent)
{
if (oDateChooser.getText() == "" oDateChooser.getText() == null)
{
oDateChooser.setValue(null);
}
}
And that is all there is to it, when the user clears the text from the wdc, the value inside is also cleared. At a postback we get the null value we wanted.
No comments:
Post a Comment