UpdatePanel实现无刷新DropdownList

updatepanel.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="updatepanel.aspx.cs" Inherits="Demo.updatepanel" %> UpdatePanel实现无刷新DropdownList

<%--Textbox发布放在UpdatePanel--%>

updatepanel.aspx.cs

using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; namespace Demo { public partial class updatepanel : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { this.txt_test.Text = "100"; } protected void ddl_test_changed(object sender, EventArgs e) { if (this.ddl_test.Text == "1") { this.txt_test.Text = "1"; } else { this.txt_test.Text = "2"; } } } }

注:vs2008环境

 

也许你也遇到过同样的问题,每次选择不同的dropdownlist选项,整个页面就会刷新一次,是不是很不爽,相比Ajax实现方式,我觉得这种方法更简单,与大家分享。

你可能感兴趣的:(ASP.NET(C#))