public class CustomEditor : Editor
{
protected override void Render(HtmlTextWriter writer)
{
Toolbar topToolbar = this.TopToolbar;
Collection<AjaxControlToolkit.HTMLEditor.ToolbarButton.CommonButton> buttons = topToolbar.Buttons;
foreach (AjaxControlToolkit.HTMLEditor.ToolbarButton.CommonButton button in buttons)
{
switch (button.GetType().Name)
{
case "Undo":
button.ToolTip = "Отменить ввод";
break;
case "Redo":
button.ToolTip = "Повторить ввод";
break;
// many others buttons
case "FixedForeColor":
button.ToolTip = "Цвет текста";
break;
case "FixedBackColor":
button.ToolTip = "Цвет выделения текста";
break;
}
}
base.Render(writer);
}
}
Almoust一切正常。问题是按钮“Fixed ForeColor”和“Fixed BackColor”。他们的工具提示没有改变(仍然是英文)。有没有解决方案?
答案 0 :(得分:1)
哦,是的。我找到了解决方案。这有点疯狂(因为我是asp.net的新手,我不知道如何正确地找到子控件。)
解决方案:带有显示工具提示的控件更深。
case "FixedForeColor":
((AjaxControlToolkit.HTMLEditor.ToolbarButton.MethodButton)button.Controls[0].Controls[0].Controls[0].Controls[0]).ToolTip = "Цвет текста";
break;
case "FixedBackColor":
((AjaxControlToolkit.HTMLEditor.ToolbarButton.MethodButton)button.Controls[0].Controls[0].Controls[0].Controls[0]).ToolTip = "Цвет выделения текста";
break;
如果有人知道如何更轻松,请发表评论。
答案 1 :(得分:1)
更简单的方法:
您可以使用索引编号管理所有按钮 在下面你可以看到他们的索引号。
protected override void Render(HtmlTextWriter writer)
{
Toolbar topToolbar = this.TopToolbar;
Collection<AjaxControlToolkit.HTMLEditor.ToolbarButton.CommonButton> buttons = topToolbar.Buttons;
buttons[0].ToolTip = "My Lovely Undo";
// Or you visible it
buttons[0].visible = false;
base.Render(writer);
}
/* List button index
[0]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.Undo}
[1]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.Redo}
[2]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.HorizontalSeparator}
[3]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.Bold}
[4]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.Italic}
[5]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.Underline}
[6]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.StrikeThrough}
[7]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.SubScript}
[8]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.SuperScript}
[9]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.HorizontalSeparator}
[10]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.Ltr}
[11]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.Rtl}
[12]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.HorizontalSeparator}
[13]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.FixedForeColor}
[14]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.ForeColorSelector}
[15]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.ForeColorClear}
[16]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.HorizontalSeparator}
[17]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.FixedBackColor}
[18]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.BackColorSelector}
[19]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.BackColorClear}
[20]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.HorizontalSeparator}
[21]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.RemoveStyles}
[22]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.HorizontalSeparator}
[23]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.FontName}
[24]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.HorizontalSeparator}
[25]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.FontSize}
[26]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.HorizontalSeparator}
[27]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.Cut}
[28]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.Copy}
[29]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.Paste}
[30]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.PasteText}
[31]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.PasteWord}
[32]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.HorizontalSeparator}
[33]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.DecreaseIndent}
[34]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.IncreaseIndent}
[35]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.HorizontalSeparator}
[36]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.Paragraph}
[37]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.JustifyLeft}
[38]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.JustifyCenter}
[39]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.JustifyRight}
[40]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.JustifyFull}
[41]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.RemoveAlignment}
[42]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.HorizontalSeparator}
[43]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.OrderedList}
[44]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.BulletedList}
[45]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.HorizontalSeparator}
[46]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.InsertHR}
[47]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.InsertLink}
[48]: {AjaxControlToolkit.HTMLEditor.ToolbarButton.RemoveLink}
*/