一。首先要利用ajax。
1,在窗体加载的方法里面,注册一段ajax的代码: Ajax.Utility.RegisterTypeForAjax(typeof(类名));
2,在后台方法前申明:[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)]
3,前台js中调用代码:var response =类名.方法名(参数)); //调用后台有返回值的方法并得到该值
A,ClientScriptManager cs = Page.ClientScript;cs.RegisterStartupScript(this.GetType(), "", "<script type=\"text/javascript\">SubjectListener();</script>");
B,Page.ClientScript.RegisterStartupScript(this.GetType(), "add2", "<script>alert('添加知识点失败!')</script>"); //弹出提示
C,Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "saveTips()", true); //后台调用页面GetType()方法
D, ClientScript.RegisterStartupScript(this.GetType(), "", "Established();", true); //这种方式同样可以调用页面中的Established()方法