AjaxControlToolkit. HTMLEditor Enable

Source: Internet
Author: User

Due to the rapid development of internal systems in the company.

Use WEB Form to quickly develop programs. Use Microsoft's own AJAX library and Toolkit

The text editor HTMLEditor in the library is used in the first time. Although the editor is small, it is basically

It meets my needs, and there are a lot of Button menus that I don't need, so I inherited the control and overwritten it.

A depressing problem occurs. Due to the editing permission problem, some content cannot be edited Based on the role.

Using Enable = false never disables content editing.

So I found that the control ActiveMode = ActiveModeType. Design (that is, the preview mode) cannot be edited.

The following is my implementation:

Step 1:

1         protected override void FillBottomToolbar()
2 {
3 if (base.Enabled)
4 {
5 BottomToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.DesignMode());
6 BottomToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.HtmlMode());
7 }
8 //BottomToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.PreviewMode());
9   }

Step 2:

1 /// <summary>
2 // rewrite Enable
3 /// </summary>
4 public override bool Enabled
5 {
6 get
7 {
8 return base. Enabled;
9}
10 set
11 {
12 base. Enabled = value;
13
14 ActiveMode = value? ActiveModeType. Design: ActiveModeType. Preview;
15
16 if (! Value)
17 {
18 BottomToolbar. Controls. Clear ();
19}
20 else
21 {
22 FillBottomToolbar ();
23}
24
25}
26}

Well, it's done. Now setting Enable = false is the result I need!

I haven't written anything for a long time. Don't knock on me.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.