Hi, I urgently need help, please.
WebtextEdit ClientSideEvent execute javascript statement on mousemove event. I can successfully change the style of another object type on this WebTextEdit ClientSide MouseMove event:document.getElementById("Object2").style.backgroundColor = '#F0F5F7';
But when I want to change the style of the WebTextEdit control:document.getElementById("WebTextEdit1").style.backgroundColor = '#F0F5F7'; Then nothing happens
When I execute the script on the same WebTextEdit Clientside for another object which is not a WebtextEdit:Object2.style.border='1px solid #FFE6A0'; Then it works
But when I want to change the WebtextEdit Clientside style:WebTextEdit1.style.border='1px solid #FFE6A0';
Then I get Error: Can't Eval WebTextEdit1.style.border='1px solid #FFE6A0';
Please Help
You want to use the CSOM of the WebTextEdit, rather than just the JavaScript DOM. The WebTextEdit object you get from one of the client-side events is a JavaScript object, but not directly an HTML element. The object does not directly have a "style" property, which is why you get this error.
The style properties, including borders, are off the Element property of the WebTextEdit control itself.
function WebTextEdit_MouseMove(oEdit, text, oEvent){ oEdit.Element.style.backgroundColor = '#F0F5F7';}
Please remember that this is a peer-to-peer forum. We'll post answers when and as we can, but we may not be able to handle "urgent" issues so quickly. For official assistance from Infragistics, particularly for urgent issues, you should likely submit a support request instead of using the forums.
Thank You for your kindness, patience & help.
Please Assist, I can't get it going: on the WebTextEdit Object (FG1010NItemD) - ClientSideEvent - MouseOver:
I tired inserting the following javascript within the MouseOver property:
FG1010NItemD.Element.style.backgroundColor = '#F0F5F7';
oEdit.FG1010NItemD.style.backgroundColor = '#F0F5F7';
oEdit.Element.style.backgroundColor = '#F0F5F7';
Aplogies for being a nuisance but please assist as I don't really know how to do this.
Please Assist!
How do I get the client side events to work with a webtextedit control in a UserControl? I have this code.
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MultiLineTextEditWithCharacterCount.ascx.cs" Inherits="CharityCheck.MultiLineTextEditWithCharacterCount" %><%@ Register tagprefix="ig" namespace="Infragistics.Web.UI.EditorControls" Assembly="Infragistics35.Web.v9.2, Version=9.2.20092.2056, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" %>
<ig:WebTextEditor ID="webTextEditor1" runat="server" BorderWidth="1px" BorderColor="#898989" Width="480px" Height="90px" TextMode="MultiLine"> </ig:WebTextEditor><br /><asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
I then do this in the Page_Load method of the UserControl based class:
scriptText = "<script type=\"text/javascript\" id=\"igClientScript\">\n" + " function keyPressInEdit(oEdit, keyCode, oEvent) {\n" + " var text = oEdit.get_value();\n" + " var ar = text.split(' ')\n" + " if (ar.length >= " + this.MaxWordCount + ")\n" + " oEvent.cancel = true;\n" + " }\n" + "</script>\n";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "keyPressInEdit", scriptText); webTextEditor1.Attributes.Add("onkeypress", "keyPressInEdit(oEdit, keyCode, oEvent)");
When I run the page with the UserControl in it and type a character in the webtexteditor, the debugger stops in the javacode at the keyPressInEdit method saying the oEdit is undefined. keyCode and oEvent are also undefined. What do I have to do to make this work
Hi David,
I think your codes will have same exception without user control. To process client events the ClientSideEvents property should be used, but not attributes or similar explicit handlers. It is ok to register handler using Page.ClientScript.RegisterClientScriptBlock if you need dynamic content.
webTextEditor1.ClientSideEvents.KeyDown = "keyPressInEditor"
Ok. I tried that and my javascript function does get called. Here is what it looks like;
<script type="text/javascript" id="igClientScript"> function keyPressInEdit(oEdit, keyCode, oEvent) { var text = oEdit.get_value(); var ar = text.split(' ') if (ar.length >= 3) oEvent.cancel = true; }</script>
The problem is that oEvent is undefined. My code breaks at the oEvent.cancel line. oEdit and keyCode are defined so that is good. How do I cancel the keypress if oEvent is undefined?
I reviewed your codes and noticed that you use Web.UI.WebTextEditor, but not WebUI.WebTextEdit.
The WebTextEditor uses client events model of its base AJAX. That includes only 2 params (similar to events of server). First param is sender which represents reference to WebTextEditor and second param is EventArgs. For KeyDown that is instance of Infragistics.Web.UI.TextEditorKeyEventArgs class. It has members get_cancel(), set_cancel(bool), get_browserEvent() and get_keyCode() members.You may add debugger; line in handler and check exact members of that param.
Hi Viktor
I was wondering how could I get the old text from the event TextChanged from the AJAX component "WebTextEditor" that only has two parameter (sender, e). I want to do something similar to the non ajax component WebTextEdit that provides a parameter with the old value.
I have been trying to ask this twice, but the for some reason the forum is not working properly with mozilla 3.6.2. Hope you get this one from IE :)
Many Thanks
Jorge from ANS
Hi Jorge,
All 3 your emails passed through.
The events on client are based on dot-net ajax framework which supports only 2 params (they mimic corresponding model on server). The 1st param is reference to owner/sender (WebTextEditor) and second param is eventArgs. In case of TextChanged event it is instance of Infragistics.Web.UI.TextEditorTextChangedEventArgs class. It has 2 methods (they are considered "properties" by dot-net-ajax rules): get_text() and get_oldText().
To learn available features on client model, I suggest you to look at docs or you may find them directly in debugger. Under IE the debugger window will show you all members of an object. So, you may insert "debugger;" line in your handler and check methods of second param.