UpdatePanel不能更新
前台:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="/CSS/Verson2.0/Common.css" rel="stylesheet" type="text/css" />
<link href="/CSS/Verson2.0/css.css" rel="stylesheet" type="text/css" />
<script src="/JavaScript/jquery-1.5.js" type="text/javascript"></script>
<style type="text/css">
.style1
{
width: 300px;
}
.style2
{
width: 138px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"
ChildrenAsTriggers="False">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button2" EventName="Click" />
</Triggers>
<ContentTemplate>
<div id="i1" runat="server">
<table class="style1">
<tr>
<td>
<asp:TextBox ID="TextBox1" runat="server" Width="145px" AutoPostBack="True"></asp:TextBox>
</td>
<td class="style2">
<asp:DropDownList ID="DropDownList1" runat="server" Height="16px" Width="238px"
AutoPostBack="True" >
<asp:ListItem Text="没法定假期" Value="0"></asp:ListItem>
<asp:ListItem Text="有法定假期" Value="1"></asp:ListItem>
<asp:ListItem Text="没法定假期周末周日休息" Value="2"></asp:ListItem>
<asp:ListItem Text="有法定假期也周末周日休息" Value="3"></asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button1" runat="server" Text="刷新2" Width="107px"
onclick="Button2_Click" />
</td>
<td class="style2">
<asp:DropDownList ID="DropDownList3" runat="server" Height="16px" Width="238px" AutoPostBack="True" >
<asp:ListItem Text="没法定假期" Value="0"></asp:ListItem>
<asp:ListItem Text="有法定假期" Value="1"></asp:ListItem>
<asp:ListItem Text="没法定假期周末周日休息" Value="2"></asp:ListItem>
<asp:ListItem Text="有法定假期也周末周日休息" Value="3"></asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<p> </p>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional"
ChildrenAsTriggers="False">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
</Triggers>
<ContentTemplate>
<div id="i2" runat="server">
<table class="style1">
<tr>
<td>
<asp:TextBox ID="TextBox2" runat="server" Width="147px" AutoPostBack="True"></asp:TextBox>
</td>
<td>
<asp:DropDownList Width="238px" ID="cdlGeneral" runat="server"
AutoPostBack="True" >
<asp:ListItem Text="没法定假期" Value="0"></asp:ListItem>
<asp:ListItem Text="有法定假期" Value="1"></asp:ListItem>
<asp:ListItem Text="没法定假期周末周日休息" Value="2"></asp:ListItem>
<asp:ListItem Text="有法定假期也周末周日休息" Value="3"></asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text="刷新1"
Width="111px" />
</td>
<td>
</td>
</tr>
</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
后台:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DropDownList1.Items[1].Selected = true;
DropDownList3.Items[1].Selected = true;
cdlGeneral.Items[1].Selected = true;
}
protected void Button1_Click(object sender, EventArgs e)
{
TextBox2.Text = DropDownList1.SelectedItem.Text;
UpdatePanel2.Update();
}
protected void Button2_Click(object sender, EventArgs e)
{
TextBox1.Text = cdlGeneral.SelectedItem.Text;
UpdatePanel1.Update();
}
}