在VS2008开发的网站系统中,在C#后台代码页面中使用到了AJAX的功能,但是运行后没有什么反应。。是不是需要安装什么控件呢?不是说VS2008已经集成的AJAX的控件组件了吗如果要实现AJAX的功能,具体要怎么操作,还要再安装些什么东西呢?
下面是涉及到AJAX的代码:protected void CheckPagerName_Click(object sender, EventArgs e)
{
AjaxCommond ac = new AjaxCommond();
SqlDataReader read = ExceRead("select * from Papermr where PaperName='" + this.txtPaperName.Text + "'");
read.Read();
if (read.HasRows)
{
if (this.txtPaperName.Text == read["PaperName"].ToString())
{
//弹出AJAX环境中的对话框
ac.OpenDialogForButton((Button)sender, "很遗憾!该试卷名称已经存在!!!");
}
}
else
{
//弹出AJAX环境中的对话框
ac.OpenDialogForButton((Button)sender, "恭喜您!该试卷名称可以添加!!!");
}
read.Close();
}
//将生成试卷保存到数据库
protected void imgBtnSave_Click(object sender, EventArgs e)
{
DataBase database = new DataBase();//实例化公共类DataBase
AjaxCommond ac = new AjaxCommond();//实例化公共类AjaxCommond
string insertExamPage = "insert into Papermr(CourseID,PaperName,PaperState) values(" + int.Parse(MyddlCourse.SelectedValue) + ",'" + txtPaperName.Text + "',1) SELECT @@IDENTITY as id";
int autopageID = GetIDInsert(insertExamPage);//保存试卷,并返回自动生成的试卷编号
if (autopageID > 0)
{
.....
.....
}
//弹出ajax环境中的提示对话框
ac.OpenDialogForButton((Button)sender, "数据保存成功!");
//跳转到试卷维护页
Response.Redirect("PaperLists.aspx");
}
麻烦各位细心解答一下~
下面是涉及到AJAX的代码:protected void CheckPagerName_Click(object sender, EventArgs e)
{
AjaxCommond ac = new AjaxCommond();
SqlDataReader read = ExceRead("select * from Papermr where PaperName='" + this.txtPaperName.Text + "'");
read.Read();
if (read.HasRows)
{
if (this.txtPaperName.Text == read["PaperName"].ToString())
{
//弹出AJAX环境中的对话框
ac.OpenDialogForButton((Button)sender, "很遗憾!该试卷名称已经存在!!!");
}
}
else
{
//弹出AJAX环境中的对话框
ac.OpenDialogForButton((Button)sender, "恭喜您!该试卷名称可以添加!!!");
}
read.Close();
}
//将生成试卷保存到数据库
protected void imgBtnSave_Click(object sender, EventArgs e)
{
DataBase database = new DataBase();//实例化公共类DataBase
AjaxCommond ac = new AjaxCommond();//实例化公共类AjaxCommond
string insertExamPage = "insert into Papermr(CourseID,PaperName,PaperState) values(" + int.Parse(MyddlCourse.SelectedValue) + ",'" + txtPaperName.Text + "',1) SELECT @@IDENTITY as id";
int autopageID = GetIDInsert(insertExamPage);//保存试卷,并返回自动生成的试卷编号
if (autopageID > 0)
{
.....
.....
}
//弹出ajax环境中的提示对话框
ac.OpenDialogForButton((Button)sender, "数据保存成功!");
//跳转到试卷维护页
Response.Redirect("PaperLists.aspx");
}
麻烦各位细心解答一下~
namespace OnLineExam.AjaxClass
{
/// <summary>
/// AjaxCommond 的摘要说明
/// </summary>
public class AjaxCommond
{
public AjaxCommond()
{
// TODO: 在此处添加构造函数逻辑
}
///<summary>
///在ASP.NET AJAX环境中,为Button控件弹出一个提示对话框
///</summary>
///<param name="button">Button控件</param>
///<param name="message">对话框中的消息</param>
public void OpenDialogForButton(Button button, string message)
{
ScriptManager.RegisterClientScriptBlock(button,typeof(Button),
DateTime.Now.ToString().Replace(":", " "),///使用当前时间作为标识
"alert('" + message + "')",true);
}
///<summary>
///在ASP.NET AJAX环境中,为Page对象弹出一个提示对话框
///</summary>
///<param name="button">Page对象</param>
///<param name="message">对话框中的消息</param>
public void OpenDialogForPage(Page page, string message)
{
ScriptManager.RegisterClientScriptBlock(page,typeof(Page),
DateTime.Now.ToString().Replace(":", " "),///使用当前时间作为标识
"alert('" + message + "')",true);
}
}