没有找到合适的产品?
联系客服协助选型:023-68661681
提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
翻译|其它|编辑:郝浩|2007-08-17 10:01:16.000|阅读 1283 次
概述:
# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>
添加一个 WebService.asmx
添加标签:[System.Web.Script]
Get
{
Lock(objectLock)//在lock里是一个临界区,在这个临界区只能有一个线程,要有其它线程调用必须等这个线程释放才可以.由 private static XmlDocument xmlDoc;进行线程程操作
{
xmlDoc.Load(HttpContext.Current.Server.MapPath(“~/App_Data/XML.xml”)// 加载文件
}
return xmlDoc;
}
public static string[] Hierarch//用于返回交节点和子节点//
{
get{return new string[] {“province”,”city”};}
}
public AjaxControlToolkit.CascadingDropDownNameValue[] GetDropDownContents(string knowCategoryValues ,string category)
//province name=”江苏,values值就是江苏,category 就是province
{//StringDictionary需要using System.Collections.Specialized
StringDictionary knownCataegoryValuesDictionary = AjaxControlToolkit.CascadingDropDown.ParaseKnowCategoryValuesString(knowCategoryValues);//将value值转换成StringDictionary类的一个
}
三个 DropDownList
中的 CascadingDropDown1,2,3(CascadingDropDown)
Category:对应着的1,2,3分别填 province,city,county
LoadingText:正在加载
ParentControlID:第一个 CascadingDropDown1不用写,这里实现一个连动效果,当选择省的时候,第二个就会出现相应的市,第三个出现县
所以第二个与第三个分别选择 DropDownList1,DropDownList2
PromptText 分别真请选择省,请选择市,请选择县
ServiceMethod:都填写 GetDropDownContents
ServicePath:都填写 WebService.asmx
更 UpdatePanel 属性的 Triggers(Collection)添加,更改 ControlID为DropDownList3,EventName 为 SelectedIndexChange 这个是触发事件
UpdatePanel1 的 RenderMode 更改为 Inline 是内嵌式的,UpdateMode 选择 Conditional
编写 DropDownList3_SelectedIndexChanged(object sender,EventArgs e)
在 Deault.aspx 中的第一个<>中加入 EnableEventValidation=”false”否则 Lable1 会出错,而且还要修改第三 DropDownList 选择它的小三角 AutoPostPack 画勾
代码如下 :
Default.aspx.cs
using System;
using System.Data;
using System.Configuration;
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;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList3.SelectedItem.Text == "")
{
this.Label1.Text = "您还有一项没有选择哦!";
}
else
{
Label1.Text = "您的籍贯是" + DropDownList1.SelectedItem.Text+ DropDownList2.SelectedItem.Text + DropDownList3.SelectedItem.Text;
}
}
}
WebService.cs
using System;
using System.Web;
using System.Collections.Specialized;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml;
/// <summary>
/// WebService 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]//添加标签,从客户端调用服务端 WebService 方法时
public class WebService : System.Web.Services.WebService
{
public WebService()
{
//如果使用设计的组件,请取消注释以下行
//InitializeComponent();
}
private static XmlDocument xmlDoc;
private static object objectLock = new object();
public static XmlDocument Document
{
get
{
lock (objectLock)//在 lock 里是一个临界区,在这个临界区只能有一个线程,要有其它线程调用必须等这个线程释放才可以.由 private static XmlDocument xmlDoc;进行线程程操作
{
if (xmlDoc == null)
{
xmlDoc = new XmlDocument();
xmlDoc.Load(HttpContext.Current.Server.MapPath("~/App_Data/XML.xml"));// 加载文件
}
}
return xmlDoc;
}
}
public static string[] Hierarchy
{
get { return new string[] { "province", "city" }; } //用于返回交节点和子节点
}
[WebMethod]
public AjaxControlToolkit.CascadingDropDownNameValue[] GetDropDownContents(string knownCategoryValues, string category)
//province name=江苏,values 值就是江苏,category 就是 province
{
//StringDictionary 需要 using System.Collections.Speciallized
StringDictionary knownCategoryValuesDictionary = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);//将 value 值转换成 StringDictionary 类的一个
return AjaxControlToolkit.CascadingDropDown.QuerySimpleCascadingDropDownDocument(Document, Hierarchy, knownCategoryValuesDictionary, category);//返回 XML 上的信息显示到界面上来
}
}
XML.xml
<?xml version="1.0" encoding="utf-8"?>
<WebServer>
<!--根节点 -->
<province name="江苏"><!—也可以通过单击右键 查看数据风格 打开一个表进行数据添加 -->
<city name="盐城市">
<country name="建湖县" />
<country name="盐城县" />
</city>
<city name="南通市">
<country name="海安县" />
<country name="如东县" />
</city>
<city name="扬州市">
<country name="宝应县" />
</city>
</province>
<province name="广东省">
<city name="潮州市">
<country name="潮安县">
</country>
</city>
<city name="河源市">
<country name="东源县">
</country>
</city>
</province>
</WebServer>
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" EnableEventValidation="False" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body style="text-align: center">
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<table border="1">
<tr>
<td style="width: 100px">
省</td>
<td style="width: 100px">
<asp:DropDownList ID="DropDownList1" runat="server" Width="100px">
</asp:DropDownList></td>
</tr>
<tr>
<td style="width: 100px">
市</td>
<td style="width: 100px">
<asp:DropDownList ID="DropDownList2" runat="server" Width="100px">
</asp:DropDownList></td>
</tr>
<tr>
<td style="width: 100px">
县</td>
<td style="width: 100px">
<asp:DropDownList ID="DropDownList3" runat="server" Width="100px"
OnSelectedIndexChanged="DropDownList3_SelectedIndexChanged" AutoPostBack="True">
</asp:DropDownList></td>
</tr>
</table>
<div>
<cc1:CascadingDropDown ID="CascadingDropDown1" runat="server"
TargetControlID="DropDownList1" Category="province" LoadingText="正在加载...."
PromptText="请选择省份" ServiceMethod="GetDropDownContents" ServicePath="WebService.asmx">
</cc1:CascadingDropDown>
</div>
<cc1:CascadingDropDown ID="CascadingDropDown2" runat="server"
TargetControlID="DropDownList2" Category="city" ParentControlID="DropDownList1"
PromptText="请选择城市" ServiceMethod="GetDropDownContents" ServicePath="WebService.asmx" LoadingText="正在加载....">
</cc1:CascadingDropDown>
<cc1:CascadingDropDown ID="CascadingDropDown3" runat="server"
TargetControlID="DropDownList3" Category="country"
ParentControlID="DropDownList2" PromptText="请选择县"
ServiceMethod="GetDropDownContents" ServicePath="WebService.asmx" LoadingText="正在加载...">
</cc1:CascadingDropDown>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" RenderMode="Inline" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="还未选择"></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DropDownList3" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</form>
</body>
</html>
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@evget.com
文章转载自:csdn面对“数字中国”建设和中国制造2025战略实施的机遇期,中车信息公司紧跟时代的步伐,以“集约化、专业化、标准化、精益化、一体化、平台化”为工作目标,大力推进信息服务、工业软件等核心产品及业务的发展。在慧都3D解决方案的实施下,清软英泰建成了多模型来源的综合轻量化显示平台、实现文件不失真的百倍压缩比、针对模型中的大模型文件,在展示平台上进行流畅展示,提升工作效率,优化了使用体验。
本站的模型资源均免费下载,登录后即可下载。模型仅供学习交流,勿做商业用途。
本站的模型资源均免费下载,登录后即可下载。模型仅供学习交流,勿做商业用途。
本站的模型资源均免费下载,登录后即可下载。模型仅供学习交流,勿做商业用途。
服务电话
重庆/ 023-68661681
华东/ 13452821722
华南/ 18100878085
华北/ 17347785263
客户支持
技术支持咨询服务
服务热线:400-700-1020
邮箱:sales@evget.com
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢
慧都科技 版权所有 Copyright 2003-
2025 渝ICP备12000582号-13 渝公网安备
50010702500608号