Hi, I am playing arround with the WebNumericEdit Control. See below for the configuration:
<igtxt:WebNumericEdit ID="WebNumericEdit1" runat="server" ReadOnly="true" BackColor="transparent" BorderStyle="None" Font-Size="Large" HorizontalAlign="Center" ForeColor="#404040" AutoPostBack="true"><SpinButtons Display="OnRight" SpinOnReadOnly="true" Width="20" /></igtxt:WebNumericEdit>
I would like to perform an AutoPostBack when the value has been changed by the SpinButtons. But it doesn't seem to work. I even set the AutoPostBack to True and I have the following code on the server side:
Protected Sub WebNumericEdit1_ValueChange(ByVal sender As Object, ByVal e As Infragistics.WebUI.WebDataInput.ValueChangeEventArgs) Handles WebNumericEdit1.ValueChange ' ... Code ... 'End Sub
What am I missing here?Note that I set the WebNumericEdit to Read-Only and that I would like to use the SpinButtons to count one value up or down, and every time I count one value up or down, I would like to have a postback.
Thanks.
Hi,
Thank you for report. That appears like a bug and that will be fixed in hot fixes. In this situation there is no lost focus and therefore no ValueChange which triggers postback.
For now, the only solution I can suggest, is to process ClientSideEvents.Spin and trigger postback from there.
To trigger postback the oEvent.needPostBack=true; can be used. However, since Spin event is raised before value is updated, the "spin" action should be explicit. It is also possible to delay postback and call doPost (internal function). Below those 2 examples:
<script type="text/javascript">function WebNumericEdit1_Spin(oEdit, delta, oEvent){ oEdit.spin(delta); oEvent.needPostBack = true;}</script>
or
<script type="text/javascript">function WebNumericEdit1_Spin(oEdit, delta, oEvent){ window.setTimeout('igedit_getById("' + oEdit.ID + '").doPost(3)', 1);}</script>
When is the hotfix scheduled? In the second example, please show the code to hook up the spin event. Thanks.
To add a handler to a client event at visual design, you may type-in name of function directly, or you may use "Add new handler.." option. In this case editor will also generate for you javascript function with parameters.
<igtxt:WebNumericEdit ID="WebNumericEdit1" runat="server" ReadOnly="true" BackColor="transparent" BorderStyle="None" Font-Size="Large" HorizontalAlign="Center" ForeColor="#404040" AutoPostBack="true"><SpinButtons Display="OnRight" SpinOnReadOnly="true" Width="20" /> <ClientSideEvents Spin="WebNumericEdit1_Spin" /></igtxt:WebNumericEdit>
A change in source codes (fix) becomes available in public service releases in 1-2 months. I can not say exact date.
Victor,
When I try to add client side events the way you suggested. I get "failure to add SCRIPT block". I know I can type in the javascript first then just
set the clientside event but the problem is I don't know the parameters. I was hoping (and based on your reply)
the IDE will supply the parameters for me.
Is there a way to fix the failure to add SCRIPT block problem?
I gave the Infragistics controls yet another chance to work properly today.
this time - WebDateTimeEditor.
I tell it to add the InvalidValue client side event.
I get the "failure to add SCRIPT block to page" error.
I'd like to know how to get around this too. Maybe I'll try making this work again some day.
All I really care to see it do is not allow an invalid date (like '09/09/9999'. I thought that might be easy.
Since that thread is about WebDateTimeEdit and you mentioned InvalidValue, but not InvalidValueEntered, I assume that you ask about WebDateTimeEdit, but not about WebDateTimeEditor.
From point of javascript Date and server DateTime object, the date 09/09/9999 is valid. If you want to prevent entering similar date, then you may set Min/MaxValue properties or process ValueChange and "fix" resulting value dynamically. Below, I show example which fills up year field is it missing and sets null if user entered year larger than 9000.
<script type="text/javascript">function invalidValue(editor, oEvent){ var month = oEvent.month; var year = oEvent.year; var day = oEvent.day; if(day != null && day > 0 && month != null && month >= 0) { var date = null; if(year < 0) oEvent.date = new Date(2010, month - 1, day); else if(year > 9000) oEvent.date = null; }}</script><igtxt:WebDateTimeEdit ID="WebDateTimeEdit1" runat="server" MinValue="1955-02-19" MaxValue="2200-01-31"> <ClientSideEvents InvalidValue="invalidValue" /></igtxt:WebDateTimeEdit>
Thank you Viktor. That works fine!