在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");
}
麻烦各位细心解答一下~
解决方案 »
- C# winform 向Excel中插入图片问题
- 字符串反转问题
- WinForm listbox 如何设置 value?
- c# winform:StatusStrip应用!!!谢谢!!
- 【急】使用c#产生数据发往指定服务器
- 多个项目时如何发布.................................在线等......急!!!!!!!!!!!!!!!!!!!
- 请问在知道窗口名的情况下打开窗口?
- (狂急)DataGrid修改后如何更新数据库问题!!!进来有分!!
- 问个引用DELPHI的DLL的问题
- 在线等待:急,急,急。如何用C#获取Web应用程序标题上的关闭。
- 关于list的float报错问题
- ADO.NET中LINQ查询问题
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);
}
}