Ajax Toolkit Editor in ListView does not render toolbars
I am attempting to use the Ajax Toolkit's HTML Editor in a ListView, but unfortunately it's not rendering the toolbars when I do. It actually appears that the Javascript simply isn't initializing. If I move the editor tag outside of the ListView on the same page it works.
<asp:ListView runat="server" ID="lstValues">
<LayoutTemplate>
<tr runat="server" id="itemPlaceholder" />
</LayoutTemplate>
<ItemTemplate>
<tr>
<th>
<asp:HiddenField runat="server" Value='<%# Eval("ContentControlAttributeUID") %>'
ID="hidAttributeUID" />
<asp:Label runat="server" Text='<%# Eval("ContentControlAttributeName") %>' />
</th>
<td>
<ajaxToolkit:Editor ID="htmlValue" runat="server" Height="300px" Width="800px"/>
</td>
</tr>
</ItemTemplate>
</asp:ListView>
IE reports the following error:
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; HPNTDF; .NET4.0C; .NET4.0E) Timestamp: Fri, 13 Aug 2010 开发者_运维技巧18:18:36 UTC
Message: Sys.ArgumentNullException: Value cannot be null. Parameter name: elements Line: 4868 Char: 12 Code: 0 URI: http://localhost:53791/ScriptResource.axd?d=-CwDSaVoJV5wizpX17LGeWO_begkXaYUs_-h1AdeNqc_WMOXUiDMagM5BMZHVvgp0&t=ffffffffbd2983fc
in my case the problem was due to the new client id naming mode introduced in asp.net 4.0. My site is set to use the new "Predictable" mode, and setting the ListView to "AutoID" did the trick. Try your sample again but with the below property added:
<asp:ListView runat="server" ID="lstValues" ClientIDMode="AutoID">
Good Luck
精彩评论