结合MS AJAX将资源文件编译到动态链接库
来源:互联网 发布:linux log4日志文件 编辑:程序博客网 时间:2024/05/18 16:36
一、创建类库项目LocalizingScriptResources。
二、添加System.Web 和 System.Web.Extensions命名控件引用。
三、添加一个Jscript文件。
四、将如下代码加入到js文件中:
function CheckAnswer()
{
var firstInt = $get('firstNumber').innerText;
var secondInt = $get('secondNumber').innerText;
var userAnswer = $get('userAnswer');
if (parseInt(firstInt)+parseInt(secondInt) ==userAnswer.value)
{
alert(Answer.Correct);
return true;
}
else
{
alert(Answer.Incorrect);
return false;
}
}
{
var firstInt = $get('firstNumber').innerText;
var secondInt = $get('secondNumber').innerText;
var userAnswer = $get('userAnswer');
if (parseInt(firstInt)+parseInt(secondInt) ==userAnswer.value)
{
alert(Answer.Correct);
return true;
}
else
{
alert(Answer.Incorrect);
return false;
}
}
五、右键js文件的属性,在高级里将“生成操作”设置成“嵌入的资源”。
六、添加类ClientVerification代码如下:
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Resources;
namespace LocalizingScriptResources
{
public class ClientVerification : Control
{
private Button _button;
private Label _firstLabel;
private Label _secondLabel;
private TextBox _answer;
private int _firstInt;
private int _secondInt;
protected override void CreateChildControls()
{
Random random = new Random();
_firstInt = random.Next(0, 20);
_secondInt = random.Next(0, 20);
ResourceManager rm = new ResourceManager("LocalizingScriptResources.VerificationResources", this.GetType().Assembly);
Controls.Clear();
_firstLabel = new Label();
_firstLabel.ID = "firstNumber";
_firstLabel.Text = _firstInt.ToString();
_secondLabel = new Label();
_secondLabel.ID = "secondNumber";
_secondLabel.Text = _secondInt.ToString();
_answer = new TextBox();
_answer.ID = "userAnswer";
_button = new Button();
_button.ID = "Button";
_button.Text = rm.GetString("Verify");
_button.OnClientClick = "return CheckAnswer();";
Controls.Add(_firstLabel);
Controls.Add(new LiteralControl(" + "));
Controls.Add(_secondLabel);
Controls.Add(new LiteralControl(" = "));
Controls.Add(_answer);
Controls.Add(_button);
}
}
}
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Resources;
namespace LocalizingScriptResources
{
public class ClientVerification : Control
{
private Button _button;
private Label _firstLabel;
private Label _secondLabel;
private TextBox _answer;
private int _firstInt;
private int _secondInt;
protected override void CreateChildControls()
{
Random random = new Random();
_firstInt = random.Next(0, 20);
_secondInt = random.Next(0, 20);
ResourceManager rm = new ResourceManager("LocalizingScriptResources.VerificationResources", this.GetType().Assembly);
Controls.Clear();
_firstLabel = new Label();
_firstLabel.ID = "firstNumber";
_firstLabel.Text = _firstInt.ToString();
_secondLabel = new Label();
_secondLabel.ID = "secondNumber";
_secondLabel.Text = _secondInt.ToString();
_answer = new TextBox();
_answer.ID = "userAnswer";
_button = new Button();
_button.ID = "Button";
_button.Text = rm.GetString("Verify");
_button.OnClientClick = "return CheckAnswer();";
Controls.Add(_firstLabel);
Controls.Add(new LiteralControl(" + "));
Controls.Add(_secondLabel);
Controls.Add(new LiteralControl(" = "));
Controls.Add(_answer);
Controls.Add(_button);
}
}
}
上边的代码创建了一个ASP.NET控件。这个控件包含两个文本框、一个Label控件,和一个按钮。Label控件用来显示两个随机的数字,往文本框里输入这两个数字的和,点击按钮就会调用CheckAnswer函数。
七、向项目中添加一个资源文件VerificationResources.resx。
八、添加三个字符串资源,如下:
名称 值
Correct Yes, your answer is correct。
Incorrect No, your answer is incorrect。
Verify Verify Answer
- 结合MS AJAX将资源文件编译到动态链接库
- MS SQLServer 资源链接
- LoadResourceDll类,载入资源中的动态链接库(dll)文件,把DLL打包到EXE文件里面
- Makefile 编译动态库文件及链接动态库
- 将js文件编译成动态链接库(dll)文件
- 将js文件编译成动态链接库(ddl)文件
- 将js文件编译成动态链接库(dll)文件
- 将js文件编译成动态链接库(dll)文件
- 利用资源文件解决动态链接库地狱的…
- 载入资源中的动态链接库(dll)文件
- 将函数、类、资源保存到动态库中
- 编译动态链接库
- Android 源码编译:资源树下,将drawable-*等文件编译到.apk里
- Qt将接口文件制作成dll动态链接库
- GCC编译生成动态链接库*.so文件
- C++中编译生成dll(动态链接库)文件
- Linux下gcc编译生成动态链接库*.so文件
- Visual Basic 编译真正的Dll动态链接库文件
- 利用ASP.NET AJAX实现表格更新程序
- 网页弹出广告代码大全
- 用AJAX实现google输入自动完成的简单模拟
- 这是一个鼠标拖动网页窗体的简单例子
- ASP.NET AJAX正式版带来的Validator问题及解决方案
- 结合MS AJAX将资源文件编译到动态链接库
- Debian Linux下JDK配置方法
- 客户端缓存
- Application.properties中把中文转为Ascii码
- 用遗传算法加强足球游戏的人工智能
- Linux系统后门技术(隐藏帐户篇)注:已发表在《黑客手册》第6期
- Linux下代码内存泄露检查工具valgrind
- ASP.NET 2.0中实现模板中的数据绑定
- WBSA发表2008后的十七大趋势报告之六:就业——失业而毕业