AjaxPro.Utility.RegisterTypeForAjax DropDownList三级联动

执行的类:

None.gif public   class  AjaxMethod
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif    [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.Read)]
InBlock.gif    
public DataSet GetDepartmentList(string CorpCd)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        ChooseEmployeeDSTableAdapters.DepartmentsTableAdapter adapter 
= new ChooseEmployeeDSTableAdapters.DepartmentsTableAdapter();
InBlock.gif        ChooseEmployeeDS.DepartmentsDataTable table 
= adapter.GetData(CorpCd);
InBlock.gif
InBlock.gif        DataSet ds 
= new DataSet();
InBlock.gif        ds.Tables.Add(table);
InBlock.gif
InBlock.gif        
return ds;
ExpandedSubBlockEnd.gif    }

InBlock.gif
InBlock.gif    [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.Read)]
InBlock.gif    
public DataSet GetItemList(string DepartmentCd)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        ChooseEmployeeDSTableAdapters.ProjectsTableAdapter adapter 
= new ChooseEmployeeDSTableAdapters.ProjectsTableAdapter();
InBlock.gif        ChooseEmployeeDS.ProjectsDataTable table 
= adapter.GetData(DepartmentCd);
InBlock.gif
InBlock.gif        DataSet ds 
= new DataSet();
InBlock.gif        ds.Tables.Add(table);
InBlock.gif
InBlock.gif        
return ds;
ExpandedSubBlockEnd.gif    }

InBlock.gif
ExpandedBlockEnd.gif}

None.gif


调用的页面.CS

None.gifusing System;
None.gif
using System.Data;
None.gif
using System.Configuration;
None.gif
using System.Collections;
None.gif
using System.Web;
None.gif
using System.Web.Security;
None.gif
using System.Web.UI;
None.gif
using System.Web.UI.WebControls;
None.gif
using System.Web.UI.WebControls.WebParts;
None.gif
using System.Web.UI.HtmlControls;
None.gif
using BITOC.Portal.Lib;
None.gif
None.gif
public partial class Employee_ChooseEmployee : PortalBasePage
ExpandedBlockStart.gif
{
InBlock.gif
InBlock.gif    
protected void Page_Load(object sender, EventArgs e)
ExpandedSubBlockStart.gif    
{
InBlock.gif        AjaxPro.Utility.RegisterTypeForAjax(
typeof(AjaxMethod), this);
InBlock.gif
InBlock.gif
InBlock.gif        
if (!Page.IsPostBack && !Page.IsCallback)
ExpandedSubBlockStart.gif        
{
InBlock.gif            ddlCorp.Attributes.Add(
"onclick""DepartmentResult();");
InBlock.gif            ddlDepartment.Attributes.Add(
"onclick""ItemResult();"); InBlock.gif
ExpandedSubBlockEnd.gif        }else    {
InBlock.gif            string corp=Request.Form["corp"];
    InBlock.gif     

             string depart=Request.Form["ddlDepartment"];

           }

      
ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}


调用的页面.ASPX

None.gif <% @ Page Language = " C# "  EnableEventValidation = " false "  AutoEventWireup = " true "  CodeFile = " ChooseEmployee.aspx.cs "  Inherits = " Employee_ChooseEmployee "   %>
None.gif
None.gif
<! DOCTYPE html PUBLIC  " -//W3C//DTD XHTML 1.0 Transitional//EN "   " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " >
None.gif
None.gif
< html xmlns = " http://www.w3.org/1999/xhtml "   >
None.gif
< head runat = " server " >
None.gif    
< title </ title >
None.gif    
None.gif    
< script type = " text/javascript " >
None.gif    
None.gif    function DepartmentResult()
ExpandedBlockStart.gif    
{
InBlock.gif        var ddlCorp 
= document.getElementById("ddlCorp");
InBlock.gif        AjaxMethod.GetDepartmentList(ddlCorp.value,get_Department_Result_CallBack);
InBlock.gif
InBlock.gif        ItemResult();
ExpandedBlockEnd.gif    }

None.gif    
None.gif    function get_Department_Result_CallBack(response)
ExpandedBlockStart.gif    
{
InBlock.gif        
if (response.value != null)
ExpandedSubBlockStart.gif        
{
InBlock.gif            document.all(
"ddlDepartment").length=0;    
InBlock.gif            var ds 
= response.value;
InBlock.gif            
if(ds != null && typeof(ds) == "object" && ds.Tables != null)
ExpandedSubBlockStart.gif            
{
InBlock.gif                document.all(
"ddlDepartment").options.add(new Option(""""));
InBlock.gif                
InBlock.gif                
for(var i=0; i<ds.Tables[0].Rows.length; i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
{
InBlock.gif                    var name
=ds.Tables[0].Rows[i].NameChs;
InBlock.gif                    var id
=ds.Tables[0].Rows[i].DepartmentCd;
InBlock.gif                    document.all(
"ddlDepartment").options.add(new Option(name,id));
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
return;
ExpandedBlockEnd.gif    }

None.gif    
None.gif    
None.gif    function ItemResult()
ExpandedBlockStart.gif    
{
InBlock.gif        var ddlDepartment 
= document.getElementById("ddlDepartment");
InBlock.gif        AjaxMethod.GetItemList(ddlDepartment.value, get_item_Result_CallBack);
ExpandedBlockEnd.gif    }

None.gif    
None.gif    
None.gif    function get_item_Result_CallBack(response)
ExpandedBlockStart.gif    
{
InBlock.gif        
if (response.value != null)
ExpandedSubBlockStart.gif        
{
InBlock.gif            document.all(
"ddlItem").length=0;    
InBlock.gif            var ds 
= response.value;
InBlock.gif            
if(ds != null && typeof(ds) == "object" && ds.Tables != null)
ExpandedSubBlockStart.gif            
{
InBlock.gif                document.all(
"ddlItem").options.add(new Option(""""));
InBlock.gif                
InBlock.gif                
for(var i=0; i<ds.Tables[0].Rows.length; i++)
ExpandedSubBlockStart.gif                
{
InBlock.gif                    var name 
= ds.Tables[0].Rows[i].Name;
InBlock.gif                    var id 
= ds.Tables[0].Rows[i].ProjectCd;
InBlock.gif                    document.all(
"ddlItem").options.add(new Option(name,id));
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
return;
ExpandedBlockEnd.gif    }

None.gif
None.gif
None.gif    function Check_Item()
ExpandedBlockStart.gif    
{
InBlock.gif        
if(document.all("ddlCorp"!= null)
ExpandedSubBlockStart.gif        
{
InBlock.gif            
if(document.all("ddlCorp").value == "")
ExpandedSubBlockStart.gif            
{
InBlock.gif                alert(
'');
InBlock.gif                
return false;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
ExpandedBlockEnd.gif    }

None.gif    
</ script >
None.gif
</ head >
None.gif
< body onload = " DepartmentResult();ItemResult(); " >
None.gif    
< form id = " form1 "  runat = " server " >
None.gif    
< div >
None.gif    
< table style = " height: 30px " >
None.gif        
< tr >
None.gif            
< td style = " width:100px; " >
None.gif                
< asp:Literal ID = " Literal1 "  runat = " server " > 姓名 </ asp:Literal ></ td >
None.gif            
< td style = " width:300px; " >
None.gif                
< asp:TextBox ID = " txtUserName "  runat = " server "  Width = " 120px " ></ asp:TextBox >
None.gif                
& nbsp; & nbsp;
None.gif                
< asp:CheckBox ID = " chkAccord "
None.gif                    runat
= " server "  Text = " 前端一致 "   /></ td >
None.gif        
</ tr >
None.gif    
</ table >
None.gif    
</ div >
None.gif    
< asp:Panel ID = " Panel1 "  runat = " server "  Height = " 1px "  Width = " 125px " >
None.gif    
< table style = " height: 30px " >
None.gif        
< tr >
None.gif            
< td style = " width:100px; " >
None.gif                
< asp:Literal ID = " Literal2 "  runat = " server " > 公司 / 门</ asp:Literal ></ td >
None.gif            
< td style = " width:400px; " >
None.gif                
< asp:DropDownList ID = " ddlCorp "  runat = " server "  Width = " 240px "  DataSourceID = " ObjectDataSource1 "  DataTextField = " NameChs "  DataValueField = " CompanyCd " >
None.gif                
</ asp:DropDownList >& nbsp; & nbsp;  & nbsp;
None.gif                
< asp:DropDownList ID = " ddlDepartment "  runat = " server "  Width = " 120px "  DataSourceID = " ObjectDataSource3 "  DataTextField = " NameChs "  DataValueField = " DepartmentCd " >
None.gif                
</ asp:DropDownList >
None.gif                
< asp:ObjectDataSource ID = " ObjectDataSource1 "  runat = " server "  OldValuesParameterFormatString = " original_{0} "
None.gif                    SelectMethod
= " GetData "  TypeName = " ChooseEmployeeDSTableAdapters.CompaniesTableAdapter " >
None.gif                
</ asp:ObjectDataSource >
None.gif                
& nbsp; & nbsp;
None.gif                
< asp:ObjectDataSource ID = " ObjectDataSource3 "  runat = " server "  OldValuesParameterFormatString = " original_{0} "
None.gif                     SelectMethod
= " Query "  TypeName = " ChooseEmployeeDSTableAdapters.DepartmentsTableAdapter "  OnSelected = " ObjectDataSource3_Selected " >
None.gif                
</ asp:ObjectDataSource >
None.gif            
</ td >
None.gif        
</ tr >
None.gif    
</ table >
None.gif    
</ asp:Panel >
None.gif    
< div style = " height:30px " >
None.gif    
< table style = " height: 30px " >
None.gif        
< tr >
None.gif            
< td style = " width:100px; " >
None.gif                
< asp:Literal ID = " Literal3 "  runat = " server " >? </ asp:Literal ></ td >
None.gif            
< td style = " width:300px; " >
None.gif                
< asp:DropDownList ID = " ddlItem "  runat = " server "  Width = " 180px "  DataSourceID = " ObjectDataSource4 "  DataTextField = " Name "  DataValueField = " ProjectCd " >
None.gif                
</ asp:DropDownList >& nbsp;
None.gif                
< asp:ObjectDataSource ID = " ObjectDataSource4 "  runat = " server "  OldValuesParameterFormatString = " original_{0} "
None.gif                    SelectMethod
= " Query "  TypeName = " ChooseEmployeeDSTableAdapters.ProjectsTableAdapter " >
None.gif                
</ asp:ObjectDataSource >
None.gif            
</ td >
None.gif        
</ tr >
None.gif    
</ table >
None.gif    
</ div >
None.gif    
</ form >
None.gif
</ body >
None.gif
</ html >
None.gif

 

转载于:https://www.cnblogs.com/lljinz/archive/2011/09/08/2170818.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值