locked
Please Help my HtmlEditorExtender Keyup is not Working. RRS feed

  • Question

  • User-1868929400 posted

    Hi All,

    I am generating text in HtmlEditorExtender by using filereader on html file and thats making difference as my keyup is not working.Please anyone tell me how to do that.

    I am working on small assignment of advertising.

    For this i have taken ajax HtmlEditorExtender.

    And I want to create Keyup event for the same.

    But Somehow its not working.

    Will Anyone please tell me right path for it.

    my aspx is like below

    ---------------------------------------------------

    <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage3.master" AutoEventWireup="true" CodeFile="myextender.aspx.cs" Inherits="myextender" %>
    <%@ Register TagPrefix="asp" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

    <script type="text/javascript">
    Sys.Application.add_load(function () {
    var htmlEditorBox = $('.ajax__html_editor_extender_container');
    alert(htmlEditorBox);

    htmlEditorBox.keyup(function () {
    myvarvalue.innerHTML = this.textContent;
    alert(this.textContent);
    alert(myvarvalue.value);

    });
    });

    </script>

    </asp:Content>
    <asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">


    <table>
    <tr>
    <td></td>
    </tr>

    <tr>
    <td>Edit Your Ad</td>
    <td>
    <h3 style="height: 58px">Preview Of Your Ad(3x10)</h3>
    </td>
    </tr>
    <tr>
    <td>
    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager>

    <div id="myTextBoxDiv" runat="server" contenteditable="true" designMode="true">

    <asp:TextBox ID="txtbox" runat="server" AutoPostBack="true" onkeypress ="chkmehere(this)" TextMode ="MultiLine" OnTextChanged="txtbox_TextChanged" ></asp:TextBox>

    </div>

    <ajaxToolkit:HtmlEditorExtender ID="HTMLEditorExtender1" runat="server" EnableSanitization="false" TargetControlID="txtbox" >
    <Toolbar>

    <ajaxToolkit:Bold />
    <ajaxToolkit:Italic />
    <ajaxToolkit:Underline />

    <ajaxToolkit:BackgroundColorSelector />
    <ajaxToolkit:ForeColorSelector />
    <ajaxToolkit:FontNameSelector />
    <ajaxToolkit:FontSizeSelector />
    <ajaxToolkit:InsertImage />

    </Toolbar>
    </ajaxToolkit:HtmlEditorExtender>


    </td>

    <td style="border: 1px solid black; height: 377.952755906px; width: 113.3858267717px">

    <div ID="div1" runat="server" Height="446px" contenteditable="true" ></div>

    </td>

    <td>
    <asp:TextBox ID="txtcms" runat="server"></asp:TextBox></td>

    <td>
    <asp:TextBox ID="txtrate" runat="server"></asp:TextBox></td>

    </tr>

    <tr>
    <td></td>
    </tr>


    </table>
    </asp:Content>

    -----------------------------------------------------------

    and my codebehind is:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.IO;
    using System.Web.UI.HtmlControls;

    public partial class myextender : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {
    if(!IsPostBack)
    {
    string TemplateFile = Server.MapPath("Classifieds\\Bwrbox1.html");

    TextReader tr = new StreamReader(TemplateFile);

    txtbox.Text = tr.ReadToEnd();


    string TemplateFile2 = txtbox.Text;

    div1.InnerHtml = TemplateFile2;


    }

    }
    protected void txtbox_TextChanged(object sender, EventArgs e)
    {
    div1.InnerHtml = txtbox.Text;
    }
    }

    --------------------------------------------------------------------------------

    PLease Help me for this problem.

    Regards,

    Jayesh(From India,Mumbai)

    Saturday, April 5, 2014 8:50 AM

Answers

  • User-417640953 posted

    Hi Jayesh,

    Thank you post the issue to our forum.

    Based on your description, I see you want to fire the keyup event on HtmlEditorExtender editer field.

    For this issue, I made a demo below, please check it.

      <script src="//code.jquery.com/jquery-1.9.1.js"></script>
        <script>
            $(function () {
               
                Sys.Application.add_load(function () {
                    $(".ajax__html_editor_extender_texteditor").keyup(function () {
                        //show its' content...
                        alert($(this).html());
                    });
    
                })
             });
        </script>
    
    
    <div id="MyDiv">
            <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager>
            <asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" Rows="20" Width="467px"></asp:TextBox>
            <asp:HtmlEditorExtender ID="HtmlEditorExtender1" runat="server" TargetControlID="TextBox1" DisplaySourceTab="true" ></asp:HtmlEditorExtender>
            
     </div>

    Hope that helps, thanks.

    Best Regards!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 8, 2014 1:41 AM
  • User-1868929400 posted

    Respected Fuxiang Zhang Sir,

    Thanks For your reply.

    I changed the code and works fine on my system.

    Regards,

    Jayesh(From India,Mumbai)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 8, 2014 5:13 AM

All replies

  • User-417640953 posted

    Hi Jayesh,

    Thank you post the issue to our forum.

    Based on your description, I see you want to fire the keyup event on HtmlEditorExtender editer field.

    For this issue, I made a demo below, please check it.

      <script src="//code.jquery.com/jquery-1.9.1.js"></script>
        <script>
            $(function () {
               
                Sys.Application.add_load(function () {
                    $(".ajax__html_editor_extender_texteditor").keyup(function () {
                        //show its' content...
                        alert($(this).html());
                    });
    
                })
             });
        </script>
    
    
    <div id="MyDiv">
            <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager>
            <asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" Rows="20" Width="467px"></asp:TextBox>
            <asp:HtmlEditorExtender ID="HtmlEditorExtender1" runat="server" TargetControlID="TextBox1" DisplaySourceTab="true" ></asp:HtmlEditorExtender>
            
     </div>

    Hope that helps, thanks.

    Best Regards!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 8, 2014 1:41 AM
  • User-1868929400 posted

    Respected Fuxiang Zhang Sir,

    Thanks For your reply.

    I changed the code and works fine on my system.

    Regards,

    Jayesh(From India,Mumbai)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 8, 2014 5:13 AM