in

C1 Community

ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

Accessing Changed Text (sNewText) from Javascript

Last post 04-23-2008 4:20 AM by C1_DmitriM. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 01-25-2008 10:04 AM

    Accessing Changed Text (sNewText) from Javascript

    Is it possible to access the C1WebEditors changed text (sNewText) from javascript without executing the save command?

    Filed under:
  • 03-23-2008 6:52 PM In reply to

    Re: Accessing Changed Text (sNewText) from Javascript

    Hi David,

     Yes, this is possible.

    You can use following:
      var text = aC1WebEditorObj.get_text();
     aC1WebEditorObj.set_text(newText);

    Following is the list of a client side object model methods:

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    * CSOM methods (Note, you need to convert names to camel style in order to use it from javascript):
    Using methods example:
    ---------- public void ApplyBackColorForSelection(string backColor) // Apply background color for current document selection
     aC1WebEditorObj.applyBackColorForSelection("red");
    Using properties example: 
    ---------- public EditorModeEnum EditorMode
     var prevEditorMode = aC1WebEditorObj.get_editorMode();
     aC1WebEditorObj.set_editorMode("Code");
     
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    // Methods:


     
     public void ExecuteCustomCommand(string commandName) // Execute C1WebEditor command given by parameter commandName.
      Available commands: "insert_form" , "insert_textarea" , "insert_textbox" , "insert_passwordfield" , "insert_hiddenfield" , "insert_listbox" , "insert_dropdown" , "insert_radiobox" , "insert_checkbox" , "insert_imagebutton" , "insert_submitbutton" , "insert_reset" , "insert_button" , "instable" , "InsertTimeStamp"                 , "Full_Screen"         , "WYSIWYG_Mode" , "Code_Mode" , "Split_Mode" , "Save" , "backcolor" , "forecolor" , "ShowTableBorders" , "SpellCheck" , "Word_Wrap" , "insertrow", "deleterow", "insertcolumn", "deletecolumn", "insertcell", "deletecell", "mergecell", "splitcell", "Cut", "Copy", "Paste", "Italic", "Bold", "Underline", "strikethrough" , "JustifyLeft" , "JustifyCenter" , "JustifyRight" , "JustifyFull" , "subscript" , "superscript" , "insertorderedlist" , "insertunorderedlist" , "undo" , "redo"

     public void ApplyBackColorForSelection(string backColor) // Apply background color for current document selection
     public void ApplyClassNameForSelection(string className) // Apply ClassName For current document selection.
     public void ApplyForeColorForSelection(string foreColor) // Apply foreground color for current document selection
     public void ApplyFontSizeForSelection(string fontSize) // Apply Font Size For current document selection.
     public void ApplyFontForSelection(string fontName) // Apply Font For current document selection.
     public void ApplyFormatForSelection(string format) // ApplyFormat for current document selection.
     public void Focus(bool restoreSelectedElement) // This method sets focus to current content editable document in WYSIWYG mode, parameter restoreSelectedElement - optional.
     public bool CanUndo() // Returns true if WebEditor can undo action.
     public bool CanRedo() // Returns true if WebEditor can redo action
     public bool CanCopy() // Returns true if Copy action is allowed.
     public bool CanPaste() // Returns true if Paste action is allowed.
     public void DoSpellcheck() // Run spell checking.
     public void DeleteSelectionContent()       // Delete content of the current selection in the WYSIWYG editor. 
     public void Save() // Save current document by uploading it to server.
     public void SelectElement(DOMElement pElement) // Select element given by parameter pElement.
     public bool IsSaved() // Returns true if text is saved, otherwise returns false.
     public bool UndoAction() // Undo action.
     public bool RedoAction() // Redo action.
     public string GetStoredContent() // Returns previously stored HTML content.
     public void StoreContent() // Store current HTML Content to internal hidden field.
     public DOMElement GetSelectedElement() // Gets selected DOM element.
     public string GetSelectionTextContent()   // Gets string with text content of the current selection in the WYSIWYG editor.
     public string GetSelectionHTMLContent() // Gets string with HTML content of the current selection in the WYSIWYG editor.
     public bool IsCodeEditingMode() // Returns true if Code editing mode is active.
     public void InsertHTML(string sHtmlText) // Insert HTML text at current position in WYSIWG document. Note, previous selected text will be deleted.
     public object GetSelectionBookmark() // Gets Current Selection Bookmark object that can be used as parameter for method MoveToSelectionBookmark. (Applies to WYSIWYG editor).  
     public void MoveToSelectionBookmark(object aSelectionBookmark) // Restore previously saved selection. (Applies to WYSIWYG editor). 
     public string QuerySelectionClass() // Returns class what used by current selected element.
     public string QueryCommandState(string commandName) // Returns state ("ENABLED", "CHECKED", "DISABLED") of the basic command given by parameter commandName.
     public string QueryCommandValue(string commandName) // Returns value of the basic command given by parameter commandName. Returns null if command not enabled or not exists.
     public void RefreshPathSelector() // Refresh PathSelector and toolbar buttons states.
     
    // Properties: 
     public string AccessKey       // Gets or sets the access key that allows you to quickly navigate to the WebEditor.
     public string ClientObjectID  // Gets ID of the client side object associated with the control.
     public EditorModeEnum EditorMode // Editor mode (WYSIWYG=0/Code=1/Split=2). Value for this property can be specified by string or int value.
     public bool FullScreenMode // FullScreen Mode. Set this property to true if you want to switch editor to FullScreen Mode.  All client area of the page will be covered by WebEditor.
     public string FullScreenModeContainerId // Full screen mode container ID. Use this property to specify container which will be used as the parent control for FullScreenMode instead of client's area on the web page.
     public bool ShowSpellCheckerDialog // Indicates whether to show SpellChecker dialog or just allow a user to select suggestions from context menu.
     public bool ShowTableBorders  // Show table borders in WYSIWYG mode.
     public string Text // Gets or Sets WebEditor Text.
     public bool WordWrap // Indicates whether to use word wrap in source editing mode.
     public string AjaxRequestImageUrl // Url to image what will be displayed on ajax requests.
     
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

     

    Best regards, Dmitri.

  • 04-21-2008 4:11 AM In reply to

    Re: Accessing Changed Text (sNewText) from Javascript

    Hi, is this the same as using your own save submit button instead of using the save on the editor component?

    Just im using the component as a part of a larger form submit and did not want to seperate save buttons. one for entire post and one for the component.

     Only way i could achieve this was to use javascript below

    <script language="javascript" type="text/javascript">
    function DoGetText() {
     <%=C1WebEditor.ClientObjectID%>.executeCustomCommand("Save");
    }

    Then on the PageLoad event add the attribute DoGetText to my submit Button1

    Button1.Attributes.Add("onclick", "DoGetText();")

    I was also able to use the Button1.click event as per normal.

    If this is not the same issue as myself then please ignore.

    Cheers, Jason

     

     

  • 04-21-2008 3:15 PM In reply to

    Re: Accessing Changed Text (sNewText) from Javascript

    Hi,

     

    Is there any way to directly access WebEditor thext from C# code behind instead of usinf inline Javascript codr.

    I tried C1WebEditor.Text to get its text but I did not work, it just resets the content each time I press the button (ASP.Net button)

  • 04-22-2008 4:00 AM In reply to

    Re: Accessing Changed Text (sNewText) from Javascript

    Hello Osama,

    I had the same issue and after a bit of time on this i believe this control is mostly made using Javascript.

    I couldnt get the text to change without using the inbuilt save button on the component. Im sure you have noticed that if you use this button then try and retrieve the text it will show but if you dont use the button then the text wont change from the original.

    Also the TextChanged method doesnt fire unless you use the save button on the control either so i could not use this as a work around. In the end i could only get javascript to fire on the ASP.NET Button before the normal handler of Button.click so it updates the C!WebEditor.Text before i try and use this.

    If you have better luck than me please pass it on i would be interested to know.

    Seems like all the buttons in the component tho are java based and cannot access them directly otherwise

     

    Cheers, Jason

  • 04-23-2008 4:20 AM In reply to

    Re: Accessing Changed Text (sNewText) from Javascript

    Hi Jason / Osama,

    This problem will be fixed since build [2.0.20082.138]

    The problem is what WebEditor stores changed Text only when EditorMode is changed or when "Save" button clicked.
    For now, you can use following javascript workaround:

    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"></asp:ScriptManager>

    <script language="javascript" type="text/javascript">
    function
    StoreWebEditorText() {
      var editor = Sys.Application.findComponent("<%=C1WebEditor1.ClientID%>"); 
      if(editor != null) {
        editor.storeContent();
      }
    }

    </script>

    <C1WebEditor:C1WebEditor ID="C1WebEditor1" runat="server" Height="450px" Width="550px"></C1WebEditor:C1WebEditor>

    <asp:Button ID="Button1" OnClientClick="StoreWebEditorText()" runat="server" Text="Button" />

    </form>

    Best regards, Dmitri.

Page 1 of 1 (6 items)
Contact ComponentOne: 1.800.858.2739 ©1987-2008 ComponentOne LLC All Rights Reserved.