我爱江南
源自江南的问候
IT博客
首页
新随笔
联系
聚合
管理
2 Posts :: 3 Stories :: 4 Comments :: 0 Trackbacks
常用链接
我的随笔
我的评论
我参与的随笔
留言簿
(1)
给我留言
查看公开留言
查看私人留言
随笔档案
(2)
2006年7月 (2)
文章分类
(3)
C#(1)
JavaScript(1)
VB.NET(1)
相册
MyPhoto
最新随笔
1. 哇塞!!!
2. 心情不好!
搜索
最新评论
1. re: xmlhttp无刷新联动
太感谢了。。。找了N多年
--MC
2. re: 心情不好!
呵呵
--ILoveYou
3. re: xmlhttp无刷新联动
好人呐!
正需要它呢,千辛万苦终于找到vb.net的了!
--ILoveYou
4. re: 用C#制作PDF文件全攻略
好东西啊!收藏ing
--fly_angel
阅读排行榜
1. 哇塞!!!(176)
2. 心情不好!(140)
评论排行榜
1. 心情不好!(1)
2. 哇塞!!!(0)
xmlhttp无刷新联动
.aspx
<
asp:dropdownlist
id
="dlPROVINCE"
runat
="server"
Font-Size
="X-Small"
Width
="85px"
Visible
="False"
Font-Names
="宋体"
BackColor
="#FFFFC0"
AutoPostBack
="false"
></
asp:dropdownlist<asp:dropdownlist id="dlCITY" runat="server" Font-Size="X-Small" Width="85px" Visible="False" Font-Names="宋体" BackColor="#FFFFC0"
></
asp:dropdownlist
<
SCRIPT language
=
"
JavaScript
"
>
<!--
//
以XML求取DropDownList2的数据
function
XmlPost2(obj)
{
var
svalue
=
obj.value;
var
webFileUrl
=
"
?provinceid=
"
+
svalue;
var
result
=
""
;
var
xmlHttp
=
new
ActiveXObject(
"
MSXML2.XMLHTTP
"
);
xmlHttp.open(
"
POST
"
, webFileUrl,
false
);
xmlHttp.send(
""
);
result
=
xmlHttp.responseText;
if
(result
!=
""
)
{
document.all(
"
dlCity
"
).length
=
0
;
var
piArray
=
result.split(
"
,
"
);
for
(
var
i
=
1
;i
<
piArray.length;i
++
)
{
var
ary1
=
piArray[i].toString().split(
"
|
"
);
document.all(
"
dlCity
"
).options.add(
new
Option(ary1[
1
].toString(),ary1[
0
].toString()));
}
}
else
{
alert(result);
}
}
//
-->
</
SCRIPT
>
.aspx.vb
Private
Property provinceid()
Property
provinceid()
As
String
Get
If
Not
IsNothing
(ViewState(
"
provinceid
"
))
Then
If
ViewState(
"
provinceid
"
).ToString
<>
""
Then
Return
ViewState(
"
provinceid
"
).ToString
End
If
Else
If
Not
IsNothing
(Request(
"
provinceid
"
))
Then
If
Request(
"
provinceid
"
).ToString
<>
""
Then
Return
Request(
"
provinceid
"
)
End
If
Else
Return
""
End
If
End
If
End
Get
Set
(
ByVal
Value
As
String
)
ViewState(
"
provinceid
"
)
=
Value
End
Set
End Property
Private
Sub dlCity_bind()
Sub
dlCity_bind(
ByVal
id
As
String
)
Dim
mystr
As
String
=
""
If
id
<>
"
-1
"
Then
Dim
sql
As
String
=
"
select CITY_ID,CITY_NAME from T_CITY where PROVINCE_CODE = '
"
&
id
&
"
'
"
Dim
ds
As
DataSet
=
accessData.selectBySQL2(Session(
"
ID
"
), Session(
"
PSW
"
), sql)
Dim
i
As
Integer
If
ds.Tables(
0
).Rows.Count
<>
0
Then
mystr
=
"
,
"
&
"
-1
"
&
"
|
"
&
""
For
i
=
0
To
ds.Tables(
0
).Rows.Count
-
1
mystr
&=
"
,
"
&
ds.Tables(
0
).Rows(i).Item(
"
city_id
"
)
&
"
|
"
&
ds.Tables(
0
).Rows(i).Item(
"
city_name
"
)
Next
'
mystr = mystr.Substring(1)
'
mystr = mystr
End
If
Else
mystr
=
"
,
"
&
"
-1
"
&
"
|
"
&
""
End
If
Response.Write(mystr)
Response.End()
End Sub
Private
Sub Page_Load()
Sub
Page_Load(
ByVal
sender
As
System.Object,
ByVal
e
As
System.EventArgs)
Handles
MyBase
.Load
On
Error
GoTo
Err_Handler
If
Me
.IsPostBack
Then
Exit Sub
End
If
dlPROVINCE.Attributes.Add(
"
onchange
"
,
"
XmlPost2(this);
"
)
sqlstr
=
"
select * from T_PROVINCE
"
Dim
ds_province
As
DataSet
=
accessData.selectBySQL2(Session(
"
ID
"
), Session(
"
PSW
"
), sqlstr)
dlPROVINCE.DataTextField
=
"
PROVINCE_NAME
"
dlPROVINCE.DataValueField
=
"
PROVINCE_CODE
"
dlPROVINCE.DataSource
=
ds_province
dlPROVINCE.DataBind()
If
provinceid
<>
""
Then
If
provinceid
=
"
-1
"
Then
dlCity_bind(
"
-1
"
)
Else
dlCity_bind(provinceid)
End
If
End
If
Exit Sub
Err_Handler:
ErrorHandle.UnHandError(Session)
Dim
redirectstr
As
String
=
"
<script>window.parent.document.location.href=
"
&
_
Chr
(
34
)
&
"
error.aspx?msg=2
"
&
Chr
(
34
)
&
"
;</script>
"
Response.Clear()
Response.Write(redirectstr)
Response.End()
End Sub
posted on 2006-07-14 16:18
我爱江南
阅读(233)
评论(2)
编辑
收藏
引用
所属分类:
VB.NET
Feedback
#
re: xmlhttp无刷新联动
2006-07-14 16:30
ILoveYou
好人呐!
正需要它呢,千辛万苦终于找到vb.net的了!
回复
更多评论
#
re: xmlhttp无刷新联动
2009-06-06 17:10
MC
太感谢了。。。找了N多年
回复
更多评论
刷新评论列表
只有注册用户
登录
后才能发表评论。
Powered by:
IT博客
Copyright © 我爱江南