如何防止自定义ajax工具包编辑器中的ctrl-v?
你好 我已经成功地制作了一个自定义的 ajax 工具包,如我所愿,在页脚工具栏中有一些按钮。现在我也想避免 crtl-v 和右键粘贴,但搜索、搜索并尝试一切都没有结果......也许有人可以引导我走上正确的道路,我希望:)
下面是我的代码(使用在 asp.net 网页上使用 c#),这使得编辑器控件。第一部分有效,但最后一部分的 keydown 不起作用,也许完全错误?
此致, 拉斯,丹麦
我的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Windows.Forms;
using AjaxControlToolkit.HTMLEditor;
/// <summary>
/// Særlig editor tilrettet behovet hos Boost Company
/// </summary>
namespace AjaxControlToolkit.HTMLEditor.BoostToolbarButton
{
public class Bold : AjaxControlToolkit.HTMLEditor.ToolbarButton.Bold
{
public override string ToolTip
{
get { return "Fed"; }
}
}
public class Italic : AjaxControlToolkit.HTMLEditor.ToolbarButton.Italic
{
public override string ToolTip
{
get { return "Kursiv"; }
}
}
public class Cut : AjaxControlToolkit.HTMLEditor.ToolbarButton.Cut
{
public override string ToolTip
{
get { return "Klip"; }
}
}
public class Copy : AjaxControlToolkit.HTMLEditor.ToolbarButton.Copy
{
public override string ToolTip
{
get { return "Kopier"; }
}
}
public class PasteText : AjaxControlToolkit.HTMLEditor.ToolbarButton.PasteText
{
public override string ToolTip
{
get { return "Indsæt"; }
}
}
public class InsertLink : AjaxControlToolkit.HTMLEditor.ToolbarButton.InsertLink
{
public override string ToolTip
{
get { return "Indsæt/ret link"; }
}
}
}
namespace BoostKontroller
{
public class BoostEditor : Editor
{
protected override void FillTopToolbar()
{
TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.BoostToolbarButton.Bold());
TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.BoostToolbarButton.Italic());
TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.BoostToolbarButton.Cut());
TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.BoostToolbarButton.Copy());
TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.BoostToolbarButton.PasteText());
TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.BoostToolbarButton.InsertLink());
}
protected override void FillBottomToolbar()
{
}
void OnKeyDown(KeyEventArgs e)
{
if (e.Control && e.KeyCode == Keys.V)
{
Clipboard.SetText(string .Empty); ;
}
}
}
}
Hi
I have succesfully made a custom ajax toolkit with a few buttoms in the footer toolbar as I wish. Now I also want to avoid crtl-v and right-click paste, but have searched, searched and tried everything with no result ... Maybe someone can lead me on the right track, I hope :)
Here below is my code (used with c# on asp.net web pages) which makes a editor control. The first part works, but the last part with the keydown is not working and maybe completely wrong?
Best regards,
Lars, Denmark
My Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Windows.Forms;
using AjaxControlToolkit.HTMLEditor;
/// <summary>
/// Særlig editor tilrettet behovet hos Boost Company
/// </summary>
namespace AjaxControlToolkit.HTMLEditor.BoostToolbarButton
{
public class Bold : AjaxControlToolkit.HTMLEditor.ToolbarButton.Bold
{
public override string ToolTip
{
get { return "Fed"; }
}
}
public class Italic : AjaxControlToolkit.HTMLEditor.ToolbarButton.Italic
{
public override string ToolTip
{
get { return "Kursiv"; }
}
}
public class Cut : AjaxControlToolkit.HTMLEditor.ToolbarButton.Cut
{
public override string ToolTip
{
get { return "Klip"; }
}
}
public class Copy : AjaxControlToolkit.HTMLEditor.ToolbarButton.Copy
{
public override string ToolTip
{
get { return "Kopier"; }
}
}
public class PasteText : AjaxControlToolkit.HTMLEditor.ToolbarButton.PasteText
{
public override string ToolTip
{
get { return "Indsæt"; }
}
}
public class InsertLink : AjaxControlToolkit.HTMLEditor.ToolbarButton.InsertLink
{
public override string ToolTip
{
get { return "Indsæt/ret link"; }
}
}
}
namespace BoostKontroller
{
public class BoostEditor : Editor
{
protected override void FillTopToolbar()
{
TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.BoostToolbarButton.Bold());
TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.BoostToolbarButton.Italic());
TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.BoostToolbarButton.Cut());
TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.BoostToolbarButton.Copy());
TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.BoostToolbarButton.PasteText());
TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.BoostToolbarButton.InsertLink());
}
protected override void FillBottomToolbar()
{
}
void OnKeyDown(KeyEventArgs e)
{
if (e.Control && e.KeyCode == Keys.V)
{
Clipboard.SetText(string .Empty); ;
}
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你可以这样做:
_paste(false, false);
是用纯文本粘贴,如果你想要单词粘贴,函数是_paste(true, true);
sControlId
是编辑器的客户端 ID。You can do that:
_paste(false, false);
is to paste with plain text if you want the word paste the function is_paste(true, true);
sControlId
is the client id of the editor.