Ajax Control Toolkit HTML 编辑器自定义问题?
如何更改 ACT HTML 编辑器的默认设置? 我想使用“选定的粗体按钮”或默认使用 rtl 方向而不是 ltr 来加载编辑器。
我怎样才能做到这一点? 我重写了 FillTopToolbar()
方法来添加自定义按钮,但我不知道如何更改默认设置。
因为选择了默认 ltr,我想将其更改为 rtl。
How to Change default setting for ACT HTML Editor? I want to load editor with for example Selected Bold Button or with rtl direction instead of ltr defaultly.
How can I perform that?
I overrided FillTopToolbar()
method to add Custom buttons but I dont Know how to change default settings.
as Default ltr is selected I want to change it to rtl.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我编辑了答案以纠正一些问题
HTMLEditor 不提供使用服务器端代码设置这些按钮状态的方法。尽管在客户端上,它通过使用 Sys.Application.load Event。如果您在初始化程序之后、用户与 UI 交互之前运行代码,则可以在该事件处理程序中设置您想要设置的任何属性。
这是设置粗体按钮和 RTL 按钮状态所需的代码。如果您想更改其他按钮的状态,可以从这里获取:
Sys(以及 Sys.Application)是来自 ASP.Net AJAX javascript 的命名空间(由于 ScriptManager 添加的文件您添加到您的页面)。如果您使用此功能,则需要确保此行
Sys.Application.add_load(myOnLoad);
在 ASP.Net AJAX 文件加载后运行。您可以通过多种方式执行此操作:如果将脚本移至单独的文件中,您会注意到
var editor = $find('<% =youreditor.ClientID %>');
不再有效。这是因为 javascript 文件不会解析服务器标记并将其替换为服务器端值(如 aspx 页面那样)。所以这里有问题的部分是<% =youreditor.ClientID %>
。要解决这个问题,您需要执行以下操作:
将其添加到您的 aspx 标记中(在 head 部分中):
所以它看起来像这样:(
如果您使用的是母版页,您只需在 ScriptManager 下面添加 script 标记即可在你的页面中)
并在你的 JS 文件中,将其替换
为此
I edited my answer to correct some things
The HTMLEditor doesn't provide a way to set the state of those buttons using serverside code. Although, on the client, it initializes by using Sys.Application.load Event. If you ran your code after their initializers, but before the user will interact with the UI, you could then set whatever properties you want to set in that event handler.
Here is the code you need to set the bold button and the rtl buttons states. You can take it from here if you want to change the states of other buttons:
Sys (and therefore Sys.Application) is a namespace that comes from the ASP.Net AJAX javascript (file(s) that are added thanks to the ScriptManager that you add to your page). If you use this, you need to be sure that this line
Sys.Application.add_load(myOnLoad);
runs after the ASP.Net AJAX files load. You can do this a couple of ways:If you move your script into a separate file, you'll notice that
var editor = $find('<% =youreditor.ClientID %>');
no longer works. That is because javascript files do not parse out server tags and replace them with the server side value (as aspx pages do). So the part that is a problem here is<% =youreditor.ClientID %>
.To fix that, here is what you do:
Add this to your aspx markup (in the head section):
So it looks something like this:
(If you are using a Master Page, you'll just add the script tag below the ScriptManager in your page)
And in your JS file, replace this
with this
您需要使用 CSS 来执行此操作,因为编辑器控件本身不支持 RTL。以下 CSS 将方向设置为 rtl -
HTML 编辑器的默认样式可以在 Editor.css 文件中找到。
You will need to do this using CSS as the editor control doesn't support rtl natively. The following CSS will set direction to rtl -
The default styles for the HTML editor can be found in the Editor.css file.