Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# HtmlEditorExtender控件中的自定义按钮?_C#_Asp.net_Ajaxcontroltoolkit_Html Editor_Htmleditorextender - Fatal编程技术网

C# HtmlEditorExtender控件中的自定义按钮?

C# HtmlEditorExtender控件中的自定义按钮?,c#,asp.net,ajaxcontroltoolkit,html-editor,htmleditorextender,C#,Asp.net,Ajaxcontroltoolkit,Html Editor,Htmleditorextender,我急需帮助 我需要向HtmlEditorExtender控件添加一个自定义按钮,但我缺乏实际操作的技巧 我搜索了整个论坛,但没有相关的信息 如果有人愿意帮忙,我需要一个例子来帮助我解决这个问题 提前感谢。一种可能是使用javascript将其添加到包含按钮的DIV中。我是用电脑做的 如果您在Firefox中检查DIV,您会注意到它有一个名为“ajax\uuuHTML\uEditor\uExtender\uButtonContainer”的类。了解该类允许您选择容器并向其中添加您自己的自定义按钮

我急需帮助

我需要向HtmlEditorExtender控件添加一个自定义按钮,但我缺乏实际操作的技巧

我搜索了整个论坛,但没有相关的信息

如果有人愿意帮忙,我需要一个例子来帮助我解决这个问题


提前感谢。

一种可能是使用javascript将其添加到包含按钮的DIV中。我是用电脑做的

如果您在Firefox中检查DIV,您会注意到它有一个名为“ajax\uuuHTML\uEditor\uExtender\uButtonContainer”的类。了解该类允许您选择容器并向其中添加您自己的自定义按钮

为此,请在HtmlEditorExtender下面的HTML中添加以下jQuery脚本:

<script language="javascript" type="text/javascript">
    // retrieve button container div using its class
    $btnContainer = $(".ajax__html_editor_extender_buttoncontainer");

    if ($btnContainer.length == 1) {
        // append your custom button to the collection of elements within the button container div
        $btnContainer.append("<input id=\"HtmlEditorExtender_YourButtonName\" class=\"ajax__html_editor_extender_YourButtonName\" type=\"button\" name=\"YourButtonName\" title=\"YourButtonName\" style=\"width: 101px; height: 21px;\" unselectable=\"on\"></input>");
    }
</script>
按钮的外观当然取决于您,但结果可能如下所示:

最后,要添加功能,请向具有指定类的元素添加单击事件。可以在外部.js文件中执行此操作

如果要访问文本框的html,则在该单击中,您将要检索属性为contenteditable='true'的两个div中的第一个div的html。这是HtmlEditorExtender的设计视图

将以下内容添加到.js文件中:

// click event for the custom button
$("body").on("click", ".ajax__html_editor_extender_YourButtonName", function (e) {
    var $editorDiv = $("div[contenteditable='true']").first();
    alert($editorDiv.html());
})

可能有一种更有效的方法来获取设计视图,但它会起作用。

一种可能是使用javascript将其添加到包含按钮的DIV中。我是用电脑做的

如果您在Firefox中检查DIV,您会注意到它有一个名为“ajax\uuuHTML\uEditor\uExtender\uButtonContainer”的类。了解该类允许您选择容器并向其中添加您自己的自定义按钮

为此,请在HtmlEditorExtender下面的HTML中添加以下jQuery脚本:

<script language="javascript" type="text/javascript">
    // retrieve button container div using its class
    $btnContainer = $(".ajax__html_editor_extender_buttoncontainer");

    if ($btnContainer.length == 1) {
        // append your custom button to the collection of elements within the button container div
        $btnContainer.append("<input id=\"HtmlEditorExtender_YourButtonName\" class=\"ajax__html_editor_extender_YourButtonName\" type=\"button\" name=\"YourButtonName\" title=\"YourButtonName\" style=\"width: 101px; height: 21px;\" unselectable=\"on\"></input>");
    }
</script>
按钮的外观当然取决于您,但结果可能如下所示:

最后,要添加功能,请向具有指定类的元素添加单击事件。可以在外部.js文件中执行此操作

如果要访问文本框的html,则在该单击中,您将要检索属性为contenteditable='true'的两个div中的第一个div的html。这是HtmlEditorExtender的设计视图

将以下内容添加到.js文件中:

// click event for the custom button
$("body").on("click", ".ajax__html_editor_extender_YourButtonName", function (e) {
    var $editorDiv = $("div[contenteditable='true']").first();
    alert($editorDiv.html());
})

可能有一种更有效的方法来获取设计视图,但它会起作用。

那正是我当时所做的。我没有找到更好的方法,但我的问题解决了。最后我改用所见即所得编辑器,因为它解决了我所有的其他问题。我使用的编辑器的名字是TinyMCE。那正是我当时所做的。我没有找到更好的方法,但我的问题解决了。最后我改用所见即所得编辑器,因为它解决了我所有的其他问题。我使用的编辑器的名称是TinyMCE。