zoukankan
html css js c++ java
ajax笔记 显示出所城市名称 ShowCity.aspx.cs代码
下面是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
System.Text;
using
GetCommand;
//
这是一个连接数据库的DLL
public
partial
class
Ajax_ShowCity : System.Web.UI.Page, ICallbackEventHandler
...
{
/**/
///
<summary>
///
声明一个数据集对象
///
</summary>
private
DataSet lookupData
=
null
;
protected
void
Page_Load(
object
sender, EventArgs e)
...
{
string
js
=
Page.ClientScript.GetCallbackEventReference(
this
,
"
arg
"
,
"
OnServerCallComplete
"
,
"
ctx
"
,
"
OnServerCallError
"
,
true
);
//
这里false表示异步回调; true表示同步回调);
StringBuilder newFunction
=
new
StringBuilder();
newFunction.Append(
"
function StartAsyncCall(arg,ctx)
"
);
newFunction.Append(
"
{
"
);
newFunction.Append( js );
newFunction.Append(
"
}
"
);
Page.ClientScript.RegisterClientScriptBlock(
this
.GetType(),
"
NewAsyncMethod
"
, newFunction.ToString(),
true
);
/**/
///
///
是首页上显示出所有城市出来
///
this
.ShowCity();
this
.lblMessage.Text
=
SetConnection._errorStatus;
this
.lblMessage.Text
+=
SetConnection.status;
}
/**/
///
<summary>
///
显示城市
///
</summary>
private
void
ShowCity()
...
{
string
executeString
=
"
select CityID,CityName from City
"
;
GridView1.DataSource
=
this
.GetLookupValuesFromDatabase(executeString,
"
City
"
);
this
.GridView1.DataBind();
}
/**/
///
<summary>
///
返回一个数据集
///
</summary>
///
<param name="executeString">
sql语句或存储过程
</param>
///
<param name="TableName">
在内存中名和名称
</param>
///
<returns>
ds
</returns>
private
DataSet GetLookupValuesFromDatabase(
string
executeString,
string
TableName)
...
{
DataSet ds
=
GetCommand.SetConnection.getDataSet(executeString, TableName);
return
ds;
}
/**/
///
<summary>
///
返回回调结果
///
</summary>
///
<returns></returns>
public
string
GetCallbackResult()
...
{
/**/
///
///
存放City表中的城市ID号
///
StringBuilder ids
=
new
StringBuilder();
/**/
///
///
存放City表中的城市名称
///
StringBuilder names
=
new
StringBuilder();
int
rowCount
=
0
;
int
numberRows
=
lookupData.Tables[
"
City
"
].Rows.Count;
foreach
(DataRow row
in
lookupData.Tables[
"
City
"
].Rows)
...
{
rowCount
++
;
if
(rowCount
<=
numberRows)
...
{
ids.Append(row[
"
CityID
"
].ToString());
ids.Append(
"
|
"
);
names.Append(row[
"
CityName
"
].ToString());
names.Append(
"
|
"
);
}
//
if (rowCount < numberRows)
//
{
//
}
}
string
returnData
=
string
.Format(
"
{0}~{1}
"
, ids.ToString(), names.ToString());
return
returnData;
}
public
void
RaiseCallbackEvent(
string
eventArgument)
...
{
System.Threading.Thread.Sleep(
2000
);
string
executeString
=
"
select CityID,CityName from City
"
;
lookupData
=
this
.GetLookupValuesFromDatabase(executeString,
"
City
"
);
}
}
下面是html里的代码
查看全文
相关阅读:
ElasticSearch(5.5.2)在java中的使用
ElasticSearch基础
Linux中profile、bashrc、bash_profile之间的区别和联系
linux上安装启动elasticsearch-5.5.1完整步骤
linux 解压zip文件
Ubuntu Linux 环境变量PATH设置
sudo 用户添加
SecureCRT5 中文乱码
韩美林的养生秘诀——“懒人操”
实验二:线性表的实验【物联网1132-11】
原文地址:https://www.cnblogs.com/xiaotuni/p/2365813.html
最新文章
ZIP排除指定目录进行压缩
Python3发送qq邮件,测试通过
东师理想运维工具开发路线图(第一阶段)
手动安装gcc 4.8.5
访问Github慢的解决办法
CentOS6.9下安装 Pika 2.2.5(新增了拷贝安装版本的办法+对于PID的位置及数据库位置的理解)
数据遗留问题
有感于微课数据同步多次 也与云上的不一致问题,大家的思路不清楚是主要原因。
服务器老是出现502 Bad Gateway?
public_brokers
热门文章
转: python 利用EMQ实现消费者和生产者模型
SSL and SSL Certificates Explained
adb 修改手机代理方式
虚拟机网络配置详解(NAT、桥接、Hostonly)
centos7防火墙的关闭
CentOS erlang安装、emqtt
CentOS 7最小化安装后找不到‘ifconfig’命令——修复小提示
centos7开机界面出现多个选项
Vmware虚拟机三种网络模式详解(转)
关于源码
Copyright © 2011-2022 走看看