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!
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.
How to change the image of WebTextEditControl from javasript?
Thanks,
AniLex
Hi AniLex,
I assume that you ask about image on custom button used by WebTextEditor.
There is no public option to modify image/css of buttons on client. However, javascript object of editor stores all data related to buttons in internal variable _buttons. You may use debugger to find these and other options. Below is example of codes, which changes image of custom button.Note: any side effects of usage internal variables are not supported.
<script type="text/javascript">function changeImg(){ var editor = $find('<%=WebTextEditor1.ClientID%>'); var buts = editor._buttons; // 0-upperspin button, 1-lowerspin button, 2-custom button var but2 = buts[2]; if(!but2) return; var imgElem = but2.imgE, images = but2.img, state = but2._state; //debugger; //alert('currentImg:' + imgElem.src + '\ncurrentState:' + state + '\nstateImages:' + images); var imageNormal = './images/butImg.gif', imageHover = './images/butImgHover.gif'; var imagePressed = './images/butImgPress.gif', imageDisabled = './images/butImgDis.gif'; but2.img = [imageNormal, imageHover, imagePressed, imageDisabled]; imgElem.src = imageNormal; //or better //imgElem.src = but2.img[state];}</script> <input type="button" value="changeImg" onclick="changeImg()" /> <ig:WebTextEditor ID="WebTextEditor1" runat="server"> <Buttons CustomButtonDisplay="OnRight"></Buttons> </ig:WebTextEditor>
Thanks for your reply.
I will try this.