• AjaxPro.Utility.RegisterTypeForAjax DropDownList三级联动


    执行的类:

    public class AjaxMethod
    {
        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.Read)]
        
    public DataSet GetDepartmentList(string CorpCd)
        
    {
            ChooseEmployeeDSTableAdapters.DepartmentsTableAdapter adapter 
    = new ChooseEmployeeDSTableAdapters.DepartmentsTableAdapter();
            ChooseEmployeeDS.DepartmentsDataTable table 
    = adapter.GetData(CorpCd);

            DataSet ds 
    = new DataSet();
            ds.Tables.Add(table);

            
    return ds;
        }


        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.Read)]
        
    public DataSet GetItemList(string DepartmentCd)
        
    {
            ChooseEmployeeDSTableAdapters.ProjectsTableAdapter adapter 
    = new ChooseEmployeeDSTableAdapters.ProjectsTableAdapter();
            ChooseEmployeeDS.ProjectsDataTable table 
    = adapter.GetData(DepartmentCd);

            DataSet ds 
    = new DataSet();
            ds.Tables.Add(table);

            
    return ds;
        }


    }


    调用的页面.CS

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using BITOC.Portal.Lib;

    public partial class Employee_ChooseEmployee : PortalBasePage
    {

        
    protected void Page_Load(object sender, EventArgs e)
        
    {
            AjaxPro.Utility.RegisterTypeForAjax(
    typeof(AjaxMethod), this);


            
    if (!Page.IsPostBack && !Page.IsCallback)
            
    {
                ddlCorp.Attributes.Add(
    "onclick""DepartmentResult();");
                ddlDepartment.Attributes.Add(
    "onclick""ItemResult();");
            }else    {
                string corp=Request.Form["corp"];
             

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

               }

          
        }

    }


    调用的页面.ASPX

    <%@ Page Language="C#" EnableEventValidation="false" AutoEventWireup="true" CodeFile="ChooseEmployee.aspx.cs" Inherits="Employee_ChooseEmployee" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        
    <title</title>
        
        
    <script type="text/javascript">
        
        function DepartmentResult()
        
    {
            var ddlCorp 
    = document.getElementById("ddlCorp");
            AjaxMethod.GetDepartmentList(ddlCorp.value,get_Department_Result_CallBack);

            ItemResult();
        }

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

                }

            }

            
    return;
        }

        
        
        function ItemResult()
        
    {
            var ddlDepartment 
    = document.getElementById("ddlDepartment");
            AjaxMethod.GetItemList(ddlDepartment.value, get_item_Result_CallBack);
        }

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

                }

            }

            
    return;
        }



        function Check_Item()
        
    {
            
    if(document.all("ddlCorp"!= null)
            
    {
                
    if(document.all("ddlCorp").value == "")
                
    {
                    alert(
    '');
                    
    return false;
                }

            }

            
        }

        
    </script>
    </head>
    <body onload="DepartmentResult();ItemResult();">
        
    <form id="form1" runat="server">
        
    <div>
        
    <table style="height: 30px">
            
    <tr>
                
    <td style="100px;">
                    
    <asp:Literal ID="Literal1" runat="server">姓名</asp:Literal></td>
                
    <td style="300px;">
                    
    <asp:TextBox ID="txtUserName" runat="server" Width="120px"></asp:TextBox>
                    
    &nbsp;&nbsp;
                    
    <asp:CheckBox ID="chkAccord"
                        runat
    ="server" Text="前端一致" /></td>
            
    </tr>
        
    </table>
        
    </div>
        
    <asp:Panel ID="Panel1" runat="server" Height="1px" Width="125px">
        
    <table style="height: 30px">
            
    <tr>
                
    <td style="100px;">
                    
    <asp:Literal ID="Literal2" runat="server">公司/门</asp:Literal></td>
                
    <td style="400px;">
                    
    <asp:DropDownList ID="ddlCorp" runat="server" Width="240px" DataSourceID="ObjectDataSource1" DataTextField="NameChs" DataValueField="CompanyCd">
                    
    </asp:DropDownList>&nbsp;&nbsp; &nbsp;
                    
    <asp:DropDownList ID="ddlDepartment" runat="server" Width="120px" DataSourceID="ObjectDataSource3" DataTextField="NameChs" DataValueField="DepartmentCd">
                    
    </asp:DropDownList>
                    
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OldValuesParameterFormatString="original_{0}"
                        SelectMethod
    ="GetData" TypeName="ChooseEmployeeDSTableAdapters.CompaniesTableAdapter">
                    
    </asp:ObjectDataSource>
                    
    &nbsp;&nbsp;
                    
    <asp:ObjectDataSource ID="ObjectDataSource3" runat="server" OldValuesParameterFormatString="original_{0}"
                         SelectMethod
    ="Query" TypeName="ChooseEmployeeDSTableAdapters.DepartmentsTableAdapter" OnSelected="ObjectDataSource3_Selected">
                    
    </asp:ObjectDataSource>
                
    </td>
            
    </tr>
        
    </table>
        
    </asp:Panel>
        
    <div style="height:30px">
        
    <table style="height: 30px">
            
    <tr>
                
    <td style="100px;">
                    
    <asp:Literal ID="Literal3" runat="server">?</asp:Literal></td>
                
    <td style="300px;">
                    
    <asp:DropDownList ID="ddlItem" runat="server" Width="180px" DataSourceID="ObjectDataSource4" DataTextField="Name" DataValueField="ProjectCd">
                    
    </asp:DropDownList>&nbsp;
                    
    <asp:ObjectDataSource ID="ObjectDataSource4" runat="server" OldValuesParameterFormatString="original_{0}"
                        SelectMethod
    ="Query" TypeName="ChooseEmployeeDSTableAdapters.ProjectsTableAdapter">
                    
    </asp:ObjectDataSource>
                
    </td>
            
    </tr>
        
    </table>
        
    </div>
        
    </form>
    </body>
    </html>
  • 相关阅读:
    mvn command is not recognized as an internal or external command
    mac搭建nginx和wordpress开发环境
    搭建nginx+php环境时遇到”file not found"的问题
    MAC下bash配置文件的加载顺序
    lsof的注意事项
    理解字符集、字符编码、ASCII、Unicode、UTF-8
    初学markdown有感
    AngularJS开发指南-Animations
    #正则表达式# 学习笔记
    vi学习笔记/基本操作方法
  • 原文地址:https://www.cnblogs.com/lljinz/p/2170818.html
Copyright © 2020-2023  润新知