gpt4 book ai didi

jquery - ckeditor getData 和 setData 不适用于 masterPage

转载 作者:行者123 更新时间:2023-12-01 03:59:33 24 4
gpt4 key购买 nike

嗨,我正在 asp.net 中使用 ckeditor。在一个简单的网页中,setData 和 getData 函数工作正常,但是当我在另一个页面继承母版页中运行相同的代码时,我收到错误。

代码是:

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<script src="js/jquery-1.10.2.min.js"></script>
<script>
$(document).ready(function () {
$('.active').click(function () {
alert(CKEDITOR.instances['txt'].getData());
})
})
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<ckeditor:ckeditorcontrol runat="server" id="txt" name="" width="870"></ckeditor:ckeditorcontrol>
<span style="margin:20px!important;cursor:pointer" class="active">testing</span>
</asp:Content>

错误是:未捕获类型错误:无法读取未定义的属性“getData”

最佳答案

系统无法读取 ckeditor 的 ID,因为使用母版页转换控件的客户端 ID,如您的示例中,没有母版页 ID 的是“txt”,而使用母版页 ID 类似于“ContentPlaceholderID_txt”。因此您可以对 ckeditor 使用 ClientIDMode="Static"。如下所示:-

<ckeditor:ckeditorcontrol runat="server" id="txt" name="" width="870" ClientIDMode="Static"></ckeditor:ckeditorcontrol>

我认为这会解决您的问题。

关于jquery - ckeditor getData 和 setData 不适用于 masterPage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51658596/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com