UpdatePanel 刷新不了
这是代码,不知道怎么回事,点击按钮刷新不了。麻烦帮忙看看
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div id="objCalender" style="width: 100%; height: 100%; overflow: auto;">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Calendar ID="Calendar1" runat="server" CellPadding="10" FirstDayOfWeek="Monday"
OnDayRender="Calendar1_DayRender" Width="100%"
BorderColor="#CCCCCC" BorderStyle="None"
BorderWidth="1px" BackColor="White" Font-Size="Large"
NextPrevFormat="ShortMonth" Height="100%">
<DayHeaderStyle BackColor="#99CCFF" BorderColor="#CCCCCC" />
<DayStyle BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1px" HorizontalAlign="Center"
VerticalAlign="Top" Font-Bold="true" />
<OtherMonthDayStyle CssClass="npDay" BackColor="#DDDDDD" ForeColor="Gray" />
<TitleStyle BorderColor="#CCCCCC" BackColor="White" Font-Bold="true" />
<WeekendDayStyle CssClass="weekend" />
</asp:Calendar>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="showDate" EventName="Click"/>
</Triggers>
</asp:UpdatePanel>
<asp:Button ID="showDate" runat="server" Text="显示" OnClick="showDate_Click" />
protected void Page_Load(object sender, EventArgs e)
{
ScriptManager1.RegisterAsyncPostBackControl(showDate);
hidDate.Value=DateTime.Now.ToShortDateString();
}
protected void showDate_Click(object sender, EventArgs e)
{
Calendar1.VisibleDate = Convert.ToDateTime(hidDate.Value.ToString());
UpdatePanel1.Update();
}
//Calendar1.VisibleDate = Convert.ToDateTime(hidDate.Value.ToString());//改为下边这句试试
Calendar1.SelectedDate = Convert.ToDateTime(hidDate.Value.ToString());
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:Button ID="Button1" runat="server" Text="刷新" onclick="Button1_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = DateTime.Now.ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = DateTime.Now.ToString();
}