最近做一些网站程序,经常要用到多个下拉菜单选择,看了介绍开始用AjaXPro这个控件,感觉效果不错。以前使用过MagicAjax,很久不用了忘记了,最麻烦的就是在虚拟目录的时候比较麻烦,呵呵,在网上也有很多,不过重要的地方经常没提醒新手,俺也是菜鸟,高手请忽略。看到这个AjaxPro使用比较简单,这次使用的是6.x的,最新的是7.x的,觉得6.0系列的方便,就选它了。
在重要的地方都有提示了,相信很容易看懂。
首先在web.config添加这个接点 在<system.web>与</system.web>之间,如下:
<system.web>
<!--for Ajaxnet-->
<httpHandlers>
<add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro.2"/>
</httpHandlers>
<!--其他设置-->
</system.web>
然后把AjaxPro.2.dll丢到bin文件夹,然后引用它就可以了。
还是发代码吧,麻烦死了下面代码是 Default.ASPx.cs的
using System;
using System.Data;
using System.Configuration;
using System.Data.OleDb;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
AjaxPro.Utility.RegisterTypeForAjax(typeof(_Default)); //必要的
if(!IsPostBack)BindDc();
}
/**//// <summary>
/// 数据库连接 http://www.knowsky.com
/// </summary>
/// <returns></returns>
public OleDbConnection myConn()
{
string ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.Web.HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["dbpath"]);
OleDbConnection conn = new OleDbConnection(ConnStr);
try
{
conn.Open();
return conn;
}
catch
{
throw;
}
