ajaxpro 2.0.dll使用方法
Default页面用ajaxpro 2.0.dll时,在前台script中写
function openclose(id)
{
admin_about.GetState(id);
}
GetState(id)是后台的一个方法,为什么调用不到这个方法呢?已经在pageload里面写
Utility.RegisterTypeForAjax(typeof(Default));
state是个方法,判断数据库中字段的值为1返回true,否则返回false
[AjaxMethod()]
public string GetState(string id)
{
if (state(id))
sql = "update about set isshow=0 where id=" + id;
else
sql = "update about set isshow=1 where id=" + id;
string tmp = DbHelperOleDb.ExecuteSql(sql).ToString();
return tmp;
}
protected void gvAboutList_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string id = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "id"));
Label lblText = (Label)e.Row.FindControl("lblText");
if (state(id))
lblText.Text = "<a href=javascript:openclose('" + id + "');>开启</a>";
else
lblText.Text = lblText.Text = "<a href=javascript:openclose('" + id + "');>关闭</a>";
}
}