UpdatePanel局部刷新用法
AjaxTest.aspx代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AjaxTest.aspx.cs" Inherits="WebApplication1.AjaxTest" %> <!DOCTYPE html>
<html>
<head runat="server">
<title>AjaxTest Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div>
<asp:Label ID="Label1" runat="server" Text="国家名称:" Font-Bold="True" Font-Size="Large"></asp:Label>
<asp:DropDownList ID="DropDownList0" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DropDownList0_SelectedIndexChanged">
<asp:ListItem Text="请选择" Value=""></asp:ListItem>
<asp:ListItem Text="亚洲" Value="亚洲"></asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DropDownList0" />
</Triggers>
</asp:UpdatePanel>
</form>
</body>
</html>
AjaxTest.aspx.cs代码:
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls; namespace WebApplication1
{
public partial class AjaxTest : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
} protected void DropDownList0_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("server=localhost;uid=techtest;pwd=techtest;database=TechTest");
string sql = "select CountryName from CountryCode";
SqlDataAdapter myAdapter = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
myAdapter.Fill(ds, "CountryCode");
this.DropDownList1.DataSource = ds.Tables["CountryCode"].DefaultView;
this.DropDownList1.DataValueField = "CountryName";
this.DropDownList1.DataTextField = "CountryName";
this.DropDownList1.DataBind();
} }
}
页面效果:


UpdatePanel局部刷新用法的更多相关文章
- updatepanel局部刷新功能,实现注册时对用户名的检测
updatepanel的使用 通过将控件放入到updatepanel中,实现局部刷新. 前台代码:<asp:ScriptManager ID="ScriptManager1" ...
- c#用UpdatePanel实现接局部刷新
通常我们看到局部刷新就会想到Ajax,但是我今天要说的是c#的一个控件,只要把服务器按钮和要刷新的区域放在该控件内就能实现局部刷新. 当然它必须和ScriptManager控件一起使用. Update ...
- updatepanel用法之triggers(局部刷新,全部刷新)使用示例
asyncpostbacktrigger(异步回调触发器):局部刷新,只刷新updatepanel内部的内容postbacktrigger(普通回调触发器):全部刷新 <asp:ScriptMa ...
- ScriptManager和UpdatePanel控件实现局部刷新
ScriptManager和UpdatePanel控件联合使用可以实现页面异步局部更新的效果.其中的UpdatePanel就是设置页面中异步局部更新区域,它必须依赖于ScriptManager存在,因 ...
- asp.net UpdatePanel 不能局部刷新问题汇总
1.web.config 配置问题. 关于web.config的配置方面网上有很多资料参考,按照其方法做即可实现. 2.网站 Framework 版本变化造成不能局部刷新问题 版本更新时,会 ...
- ASP.Net UpdatePanel控件 局部刷新 && 弹出提示信息
参考博客: https://blog.csdn.net/qq_35019337/article/details/69972552 https://blog.csdn.net/huangyezi/art ...
- C#服务控件UpdatePanel的局部刷新与属性AutoPostBack回传
C#服务控件许多都有AutoPostBack这一属性(AutoPostBack意思是自动回传,也就是说此控件值更改后是否和服务器进行交互),如下代码所示: protected void Textbox ...
- Webform——页面局部刷新
有一些数据控件,每次更改它的值后,都会重新查询数据库,然后再重新显示出来. 这样每次都会刷新全部页面,如果是一些信息量很庞大的页面,就会出现卡顿的现象,为了避免这种情况,就用到了局部刷新. 所用到的控 ...
- ASP.NET实现省市区三级联动(局部刷新)
跟前一篇ASP.NET实现年月日三级联动(局部刷新)一样,没什么技术含量,直接上代码 <asp:ScriptManager ID="ScriptManager1" runat ...
随机推荐
- C++关联容器综合应用:TextQuery小程序
本文介绍C++关联容器综合应用:TextQuery小程序(源自C++ Primer). 关于关联容器的概念及介绍,请参考园子里这篇博文:http://www.cnblogs.com/cy568sear ...
- Windows Server 2012 R2超级虚拟化之七 远程桌面服务的增强
Windows Server 2012 R2超级虚拟化之七 远程桌面服务的增强 在Windows Server 2012提供的远程桌面服务角色,使用户能够连接到虚拟桌面. RemoteApp程序.基 ...
- Redis 实践笔记
本文来自:http://www.cnblogs.com/me-sa/archive/2012/03/13/redis-in-action.html 最近在项目中实践了一下Redis,过程中遇到并解决了 ...
- URL传参中文乱码encodeURI、UrlDecode
传递参数 encodeURI("url.aspx?str"+"汉字")-----------(是 URi 不是URL) 后台接收参数 Server.Url ...
- node.js url模块
URL url.parse(urlStr[, parseQueryString][, slashesDenoteHost]) url.format(urlObj) url.resolve(from, ...
- 在Win7的IIS上搭建FTP服务及用户授权
FTP服务 FTP是文件传输协议(File Transfer Protocol)的简称,该协议属于应用层协议(端口号通常为21),用于Internet上的双向文件传输(即文件的上传和下载).在网络上有 ...
- SPL的基本使用
SPL是Standard PHP Library(PHP标准库)的缩写. 根据官方定义,它是"a collection of interfaces and classes that are ...
- ASP .Net Core 使用 Dapper 轻型ORM框架
一:优势 1,Dapper是一个轻型的ORM类.代码就一个SqlMapper.cs文件,编译后就40K的一个很小的Dll. 2,Dapper很快.Dapper的速度接近与IDataReader,取列表 ...
- [ZT]DAS\NAS\IP SAN\FC SAN之区别
DAS:服务器直接后挂存储设备,最经济的一种结构. NAS:网络上直接挂接的存储设备,其实就是处于以太网上的一台利用NFS.CIFS等网络文件系统的文件共享服务器. SAN是网络上的磁盘,NAS是一个 ...
- ajax读取txt文件
注意url为网络路径 <html><head><script type="text/javascript"> function loadXML ...