先配置webconfig,如下:
后台代码
1<configuration>
2 <appSettings>
3 <add key="ConnectionString" value="workstation id=(local);packet size=4096;user id=sa;data source=(local);persist security info=True;initial catalog=ckgl;password=sa" />
4 </appSettings>
5 <system.web>
6<httpHandlers>
7<add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory,AjaxPro" />
8</httpHandlers>
9 .
10.
11.
12</system.web>
13</configuration>
14
然后在Global.asax添加下面的内容2 <appSettings>
3 <add key="ConnectionString" value="workstation id=(local);packet size=4096;user id=sa;data source=(local);persist security info=True;initial catalog=ckgl;password=sa" />
4 </appSettings>
5 <system.web>
6<httpHandlers>
7<add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory,AjaxPro" />
8</httpHandlers>
9 .
10.
11.
12</system.web>
13</configuration>
14
1protected void Application_Start(Object sender, EventArgs e)
2 {
3 AjaxPro.Utility.HandlerPath = "ajaxpro";
4 }
怎么在代码里调用呢,这里很关键,先在后台代码Page_Load里添加:2 {
3 AjaxPro.Utility.HandlerPath = "ajaxpro";
4 }
private void Page_Load(object sender, System.EventArgs e)
{
AjaxPro.Utility.RegisterTypeForAjax(typeof(func.GetMaxId));
}
下面举个简单的例子:{
AjaxPro.Utility.RegisterTypeForAjax(typeof(func.GetMaxId));
}
后台代码
1[AjaxPro.AjaxMethod]
2 public string Get_lsbm(string dlbm,string xlbm)
3 {
4 string StrSql =@"select str(max(cast(lsbm as int))+1) from jb_lsbm where dlbm='"+dlbm.Trim()+"' and xlbm='"+xlbm.Trim()+"'";
5 func.data_operation dop1 = new func.data_operation();
6 string StrId = dop1.ExeCommMax(StrSql);
7 if(StrId==null)
8 StrId = "1";
9 return func.data_operation.StringFormat(StrId.Trim(),7).Trim();
10 }
前台脚本2 public string Get_lsbm(string dlbm,string xlbm)
3 {
4 string StrSql =@"select str(max(cast(lsbm as int))+1) from jb_lsbm where dlbm='"+dlbm.Trim()+"' and xlbm='"+xlbm.Trim()+"'";
5 func.data_operation dop1 = new func.data_operation();
6 string StrId = dop1.ExeCommMax(StrSql);
7 if(StrId==null)
8 StrId = "1";
9 return func.data_operation.StringFormat(StrId.Trim(),7).Trim();
10 }
<script>
function WOpen(form)
{
var xlbm = func.GetMaxId.Get_lsbm(str[1],str[3]).value;
form._lsbm.value=xlbm;
}
</script>
function WOpen(form)
{
var xlbm = func.GetMaxId.Get_lsbm(str[1],str[3]).value;
form._lsbm.value=xlbm;
}
</script>