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 Francis,
That can be accomplish by various ways. If you need a postback when value in editor was changed and it lost focus, then the easiest way is to process server ValueChanged event and enable auto postback on client ValueChanged event.
You also may put everything in UpdatePanel, so, postback will become invisible for end user. Below is example.
aspx:
<asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <ig:WebTextEditor ID="WebTextEditor1" runat="server" onvaluechanged="WebTextEditor1_ValueChanged"> <AutoPostBackFlags ValueChanged="On" /> </ig:WebTextEditor> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </ContentTemplate></asp:UpdatePanel>
aspx.cs:
protected void WebTextEditor1_ValueChanged(object sender, TextEditorValueChangedEventArgs e){ this.TextBox1.Text = e.NewValue as string; // or //this.TextBox1.Text = this.WebTextEditor1.Text;}
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.
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"); });
Hi Andrei,
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);}
<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>
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://www.infragistics.com/community/forums/t/83405.aspx