Hello,
When user enters ID into textbox, when they tab out I would like to initiate an event server side. The ID will hit the DB and return info on a grid. How do I call an event when user tab out of the WebTextEditor control?
Regards,
Francis
Hi Andrei,
I mentioned that application should not rely on explicit browser events for WebTextEditor. Of cource application may still use them, but result can be not reliable. WebTextEditor does not process/cancel the "change" event, though it filters and cancels almost all keyboard events, therefore browser may fail to see changes coming while type-in and "change" is not raised on blur. Though, if end user will modify value by something like Ctrl+V, then on blur the "change" might fire.
Application should use only public client events exposed by WebTextEditor.
Also something like $("#" + clientID_of_WebTextEditor) in combination with possible buttons provided by WebTextEditor (drop-down/custom or spin) will return reference not to INPUT, but to TABLE, so all key/change/focus/blur events of browser will fail.
In extreme cases application might try to hack into logic of WebTextEditor and do any custom changes, though, that is beyond support and application should handle any side effects on its own. Example to hack into firing all client events exposed by WebTextEditor:function WebTab1_Initialize(sender, eventArgs) { var tab1 = sender.getTabAt(0); var o = $find(tab1.findChild("MyTextEditor1").id); o._old_fireEvt = o._fireEvt; o._fireEvt = function(id, p2, p3, p4) { if (id === 11) { alert('ValueChanged in ' + o.get_id() + ': ' + o.get_value()); } o._old_fireEvt(id, p2, p3, p4); };}
Hello Viktor and thanks for your quick reply.
So basically if I use WebTextEditor JQuery events wont work correctly? Is there a specific design reason behind this? Or just a drawback of using javascript based controls? Is there some kind of workaround whilst still using JQuery? Such a functionality is very common and useful.
Also, I added a question on the forum after posting this comment. Tought it would be more appropiate. Here is the link: http://ko.infragistics.com/community/forums/t/83405.aspx
If you use TextBox or similar, then you may use explicit browser or jquery handlers. Though, in order to use them you should first find correct references to your INPUTs.
If you use WebTextEditor or similar javascript based controls, then you should not use jquery handlers, but you should use events exposed by ClientEvents of control. If you will use explicit handlers to browser events, then some events can be wrong (or never fires) and you will not be able to get actual value/property for control, like get_value() for WebDateTimeEditor or similar.
You also should consider timing for finding correct references to child elements/controls: not earlier than container (like WebTab) is fully initialized.Below are examples for both cases. You may copy/paste those codes in any sample and test change events.
cs:protected void Page_Load(object sender, EventArgs e){ TextBox tb = new TextBox(); tb.ID = "MyTextBox1"; this.WebTab1.Tabs[0].Controls.Add(tb); WebTextEditor te = new WebTextEditor(); te.ID = "MyTextEditor1"; te.ClientEvents.ValueChanged = "myValueChanged"; this.WebTab1.Tabs[0].Controls.Add(te);}
aspx:
<script type="text/javascript">function WebTab1_Initialize(sender, eventArgs) { var tab1 = sender.getTabAt(0); var tb = tab1.findChild("MyTextBox1"); if (tb) { $(tb).change(function() { alert("change for " + this.id + ". Value:" + this.value); } ); }}function myValueChanged(sender, evtArgs) { alert("change for " + sender.get_id() + ". Value:" + evtArgs.get_value());}</script><ig:WebTab ID="WebTab1" runat="server" Width="300px" Height="300px"> <ClientEvents Initialize="WebTab1_Initialize" /> <Tabs> <ig:ContentTabItem runat="server" Text="Tab 1"></ig:ContentTabItem> <ig:ContentTabItem runat="server" Text="Tab 2"></ig:ContentTabItem> </Tabs></ig:WebTab>
How can I do the same but client side? I'm dinamically adding controls to a webpage, and I want to be able to add a change listener to the control, but it's not working. Here is my code:
$("#IdOfControl").change(function () { alert("Justificar cambio de Área Horizontal en Observaciones"); });
Hello.
In my project from clientside clicking webdatagrid I pass cell value to webtexteditor1.And addition to clicking values of webtexteditor changing. And I want to to get value from sql using webtexteditor1_valuechanged .Please give an advice.
Thanks in advance.