r.a.d.spell默认情况下只能给一个控件做拼写检查,也就是说它是和单个控件绑定的,如微软的验证控件一样,只能检合一个。但是实际情况是,页面上有很多需要拼写检查的控件,总不能给每个控件绑定一个r.a.d.spell吧,研究了一下,通过程序可以动态的给r.a.d.spell绑定控件,从而只需拖一个r.a.d.spell就可以给任何需要拼写检查的控件做检查了。
1.控件可以到http://www.telerik.com/r.a.d.controls/Spell/Examples/WhatsNew/DefaultCS.aspx下载,我就不提供了。
2.建立测试页面,引用RadSpell.dll,拖入RadSpell控件即可
3.建立测试页面
3.1 html代码
<HTML>
<HEAD>
<title>WebForm3</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<script language="JavaScript">
function textfocus(obj)
{
BindControl(obj.id);
}
function BindControl(controlId)
{
document.getElementById('RadSpell1').l4 = new RadSpell();
document.getElementById('RadSpell1').StartSpellCheck = function()
{
RadSpell.getSpellChecker('RadSpell1').startSpellCheck();
};
var spellChecker = RadSpell.getSpellChecker('RadSpell1');
spellChecker.i5 = '/Document/RadControls/';spellChecker.I5 = 'Spell/';
spellChecker.o6 = 'RadSpell1';
spellChecker.clientId = 'RadSpell1';
spellChecker.targetControlId = controlId;
spellChecker.O5 = function()
{
return new HtmlElementTextSource(document.getElementById(controlId));
};
spellChecker.I4 = function()
{
return document.getElementById('RadSpell1_postBackStorage');
};
spellChecker.I6 = null;
spellChecker.useClassicDialogs = false;
spellChecker.language = 'en-US';
spellChecker.dictionaryLanguage = 'en-US';
spellChecker.dialogsScheme = 'Default/';
spellChecker.O6 = '<%=RadSpellUniqueId%>'
spellChecker.l6 = false;
spellChecker.i6 = '';
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:textbox id="TextBox1" style="Z-INDEX: 101; LEFT: 264px; POSITION: absolute; TOP: 32px" onfocus="textfocus(this);"
runat="server"></asp:textbox><asp:textbox id="TextBox2" style="Z-INDEX: 102; LEFT: 264px; POSITION: absolute; TOP: 72px" onfocus="textfocus(this);"
runat="server"></asp:textbox><asp:textbox id="TextBox3" style="Z-INDEX: 103; LEFT: 264px; POSITION: absolute; TOP: 112px"
onfocus="textfocus(this);" runat="server"></asp:textbox></FONT>
<radS:RadSpell id="RadSpell1" style="Z-INDEX: 105; LEFT: 48px; POSITION: absolute; TOP: 48px" Runat="server"></radS:RadSpell>
</form>
</body>
</HTML>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.TextBox TextBox2;
protected Telerik.WebControls.RadSpell RadSpell1;
protected System.Web.UI.WebControls.TextBox TextBox3;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
RadSpellUniqueId
Web Form Designer generated code
}

浙公网安备 33010602011771号