在页面page_load(.cs)时要注册类库,
//TODO: Register Cppe_Base for Ajax, only if any element in this layout can drag/drop sections.
AjaxPro.Utility.RegisterTypeForAjax(typeof(Cppe_Base));
//TODO: Register specific element for Ajax, only if any element in this layout has element specific ajax method.
AjaxPro.Utility.RegisterTypeForAjax(typCppElement);
AjaxPro.Utility.RegisterTypeForAjax(typeof(Cppg_ElementGadget_ScsnPlanOrgChart));
而后在类库中要有一个空的构造方法。
在定义的方法前要写上 [AjaxPro.AjaxMethod],修饰符为public
其中的数据库联接要如下面的形式:
string strDBConn = "Driver={SQL Server};Server=" + strCompanyDBServer + ";Database=" + strCompanyDBName + ";UID=" + strDBUser + ";PWD=";
在js文件中调用:
strTemp = SalaryCom.CompPlanner.CppElementScripts.Cppe_Stp_AddEditSeccessionPlan2.GetOrgUnitCode().value;
(格式:名称空间.类名.方法)
或者
SalaryCom.CompPlanner.CppElementScripts.Cppe_Spl_ResourcePlanningOrgChartView.AjaxGenerateOrgChartFrame(arrParam, AjaxGenerateOrgChartFrame_CallBack);
function AjaxGenerateOrgChartFrame_CallBack(res)
{
//此处的res= SalaryCom.CompPlanner.CppElementScripts.Cppe_Spl_ResourcePlanningOrgChartView.AjaxGenerateOrgChartFrame(arrParam.value.
}