[英]Update Panel must be missing something but cannot figure out what
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div id="Container" onclick="__doPostBack('UpdatePanel1', '');">
<asp:UpdatePanel runat="server" ID="UpdatePanel1"
OnLoad="UpdatePanel1_Load">
<ContentTemplate>
<asp:Label runat="server" ID="Label1" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</asp:Content>
CodeBehind 代码隐藏
public partial class _Default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void UpdatePanel1_Load(object sender, EventArgs e)
{
Label1.Text = DateTime.Now.ToString();
UpdatePanel1.Update();
}
}
I am missing something here I have done 100 times but this one time it seems to refuse to work. 我在这里错过了一些我做了100次,但有一次它似乎拒绝工作。 I just need an extra set of eyes to see what I am not. 我只需要一双额外的眼睛来看看我不是。 I am just telling an update panel to update when the div is clicked the problem is it always does a full page postback. 我只是告诉更新面板更新何时单击div,问题是它总是进行整页回发。
I tried the two suggestions below and no luck the thing that has me starching my head is that I tried it in a brand new project as well and no luck at all. 我尝试了下面的两个建议,没有运气让我头疼的事情是我在一个全新的项目中尝试过它而且没有运气。
I believe you are causing a recursion when you call Update() because it will fall again in the Load event. 我相信你在调用Update()时会导致递归,因为它会在Load事件中再次出现。 Just remove the Update() and it should work. 只需删除Update()即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.