很抱歉再次提出这个问题,我已经浏览了SO, Code Project, ASP论坛和TinyMCE论坛上的其他问题,没有任何问题。
我有一个更新面板内坐着两个模板与内容文本区域(asp:textbox)这是由折叠面板扩展器处理。在Page_Load上,两个文本区域都由TinyMCE插件控制,但是当你关闭一个并再次打开它时,文本框都没有TMCE控制器。
我试图让TinyMCE控制器填充文本区域,而不管部分回发。
我已经尝试删除所有其他jQuery插件和脚本没有效果,所以我已经排除了与其他脚本的兼容性问题。
为了澄清在我的代码中,重新初始化段与我拥有的其他插件一起工作,所以我希望它能在这里工作。
我已经精简和简化了我的代码,只包含相关的部分,如果我错过了什么,请让我知道,我会更新的问题。
任何帮助都将非常感激,谢谢。
脚本<script src="../Scripts/tinymce/tinymce.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
tinymce.init({
menubar: false,
width: 800,
height: 250,
selector: "textarea"
});
function confirm_delete() {
return confirm('Are you sure that you wish to delete this announcement?');
}
// reinitialise everything after postback
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(function () {
tinymce.init({
menubar: false,
width: 800,
height: 250,
selector: "textarea"
});
</script>
ASP更新面板
<asp:UpdatePanel ID="annupd" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional" >
<ContentTemplate>
<asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1" DataKeyNames="Id" InsertItemPosition="FirstItem" ItemPlaceholderID="lay0" OnItemCommand="ListView1_ItemCommand" AllowPaging="True" EnableViewState="true">
<EditItemTemplate>
<tr style="background-color:#fffAfC;">
<td style="width:90px;" rowspan="3">
<asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
</td>
<td >
<asp:TextBox ID="TitleTextBox" runat="server" Text='<%# Bind("Title") %>' Width="300px" />
</td>
<td>
<asp:CheckBox ID="EnabledTextBox" runat="server" Checked="SomeBind" />Enabled
</td>
</tr>
<tr >
<td colspan="4">
<asp:TextBox ID="TextBox2" runat="server" Text="SomeBind" TextMode="MultiLine" Width="100%" Rows="16"/>
</td>
</tr>
<tr style="background-color:#fffAfC;color: #FFFFFF;">
<td colspan="2">
<asp:TextBox ID="URLLinkTextBox" runat="server" Text="SomeBind" Width="100%"/>
</td>
<td colspan="1">
<asp:DropDownList ID="Group" runat="server" Text="SomeBind" Width="120px" DataSourceID="SqlDataSource0" DataTextField="GroupName" DataValueField="ID">
</asp:DropDownList>
</td>
<td colspan="1">
<asp:DropDownList ID="DLL2" runat="server" Width="120px" OnSelectedIndexChanged="DLL2_SelectedIndexChanged" AutoPostBack="true" EnableViewState="true" CausesValidation="false">
<asp:ListItem Value="0">Select</asp:ListItem>
<asp:ListItem Value="1">Option 1</asp:ListItem>
<asp:ListItem Value="2">Option 2</asp:ListItem>
</asp:DropDownList>
<td>>
</td>
</td>
</tr>
</EditItemTemplate>
<EmptyDataTemplate>
<table runat="server" style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;">
<tr>
<td>No data was returned.</td>
</tr>
</table>
</EmptyDataTemplate>
<ItemSeparatorTemplate>
<tr>
<td colspan="5" class="hr"><hr /></td>
</tr>
</ItemSeparatorTemplate>
<InsertItemTemplate>
<tr>
<td colspan="5" >
<asp:panel runat="server" ID="Panel1" >
<div style="vertical-align:middle;height:30px;">
<div style="float:left;vertical-align:top;height:20px;display:inline;padding:0px;">
<asp:ImageButton ID="cdimg" runat="server" AlternateText="+" ImageUrl="/images/expand3.jpg" BorderStyle="None" CssClass="bimg" />
</div>
<div style="float:left;vertical-align:middle;display:inline;padding:2px; cursor:pointer;"><h3> Add New Announcement</h3>
</div>
</div>
</asp:panel>
</td>
</tr>
<tr>
<td colspan="5" >
<asp:panel runat="server" ID="Panel2" CssClass="cpBody">
<table id="innert" runat="server" style="width:100%;">
<tr style="">
<td rowspan="3" style="width:90px;">
<asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" />
</td>
<td>
<asp:TextBox ID="TitleTextBox" runat="server" Text="SomeBind" Width="300px" />
</td>
<td style="width:80px;">
<asp:CheckBox ID="EnabledTextBox" runat="server" Checked="true" />Enabled
</td>
</tr>
<tr >
<td colspan="4">
<asp:TextBox ID="TextBox" runat="server" Text="SomeBind" Width="100%" TextMode="MultiLine" Rows="16" />
</td>
</tr>
<tr>
<td colspan="2">
<asp:TextBox ID="URLLinkTextBox" runat="server" Text="SomeBind" Width="100%" />
</td>
<td colspan="1">
<asp:DropDownList ID="Group" runat="server" Text="SomeBind" Width="100px" DataSourceID="SqlDataSource0" DataTextField="GroupName" DataValueField="ID" >
</asp:DropDownList>
</td>
<td colspan="1">
<asp:DropDownList ID="DDL" runat="server" Width="100px" OnSelectedIndexChanged="DDL_SelectedIndexChanged" AutoPostBack="true" CausesValidation="false" EnableViewState="true">
<asp:ListItem Value="0">Select</asp:ListItem>
<asp:ListItem Value="1">Option 1</asp:ListItem>
<asp:ListItem Value="2">Option 2</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>
</asp:panel>
<act:CollapsiblePanelExtender runat="server" ID="ocpe" TargetControlID="Panel2" CollapseControlID="Panel1" ExpandControlID="Panel1" ImageControlID="odimg" CollapsedImage="/images/expand3.jpg" ExpandedImage="/images/contract3.jpg" Collapsed="True" ExpandedSize="450">
</act:CollapsiblePanelExtender>
</td>
</tr>
</InsertItemTemplate>
<ItemTemplate>
</ItemTemplate>
<SelectedItemTemplate>
</SelectedItemTemplate>
<LayoutTemplate>
<table id="imoo" border="1" style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;width:100%;">
<thead>
<th> </th>
<th>Title</th>
<th> </th>
</thead>
<asp:literal id="lay0" runat="server"> </asp:literal>
</table>
<div id="centrepager" style="width:100%; text-align:center">
<asp:DataPager PageSize="10" PagedControlID="ListView1" runat="server" ID="ListViewPageController" QueryStringField="Id">
<Fields>
<asp:NextPreviousPagerField ShowFirstPageButton="true" ShowNextPageButton="false"/>
<asp:NumericPagerField ButtonCount="5" />
<asp:NextPreviousPagerField ShowLastPageButton="true" ShowPreviousPageButton="false"/>
</Fields>
</asp:DataPager>
</div>
</LayoutTemplate>
</asp:ListView>
</ContentTemplate>
</asp:UpdatePanel>
更新1
我正在考虑使用AJAX来解决这个问题,在部分重新加载时调用tinymce插件-这可能吗?到目前为止,尝试都失败了。
我已经尝试从page_load初始化jquery tinymce函数,如果它还没有被调用,但仍然没有。
VB。NET代码
Public Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Page.IsPostBack Then
If (Not ClientScript.IsStartupScriptRegistered("tinymce")) Then
Page.ClientScript.RegisterStartupScript _
(Me.GetType(), "tinymce", "tinymce();", True)
End If
End If
End Sub
当我试图通过jQuery做这个时,它破坏了整个插件。
function pageLoad() {
tinymce.init({
menubar: false,
width: 800,
height: 250,
selector: "textarea"
});
在下面投票,因为它让我找到了一个解决方案,scriptmanager在我的主页中,所以影响了一切。
最后我禁用了我的updatePanel -再次像你的一样,这不是这样的解决方案,但整理了textitor问题。
要填充更新面板的靴子,我将使用JQuery来替换更新面板,这些问题排序的问题,希望这有助于。
这,这是关于如何使用JQuery作为ASP更新面板的替代品的两个信息问题。
不幸的是,我找不到一种方法来通过ASP实现更新面板的功能。
为了解决时间问题,我在ScriptManagerToolkit中禁用了EnablePartialRendering
。
虽然这不是我想要的解决方案,但它是解决这个特定问题的方法-由于时间限制,这需要尽快工作。
如果/当我/别人找到一个更好的解决方案,我会更新这个线程。实现此功能的关键似乎依赖于一种回发形式,以便在部分页面加载时重新初始化timece。