UpdatePanel中的控件未更新 [英] Control in UpdatePanel is not getting Updated

查看:77
本文介绍了UpdatePanel中的控件未更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用带有某些控件的UpdatePanel.当我单击按钮时,它会创建一个睡眠.这一次,我单击第二个按钮,其处理程序成功执行异步.但是其中一个标签不会更新.为什么?

 <   body  > ; 
    <  表单    ="   form1"    ="  服务器" <   asp:ScriptManager     ID   ="   runat   服务器" <   asp:UpdatePanel     ChildrenAsTriggers   ="   ID    UpdatePanel1 "    ="    <   contenttemplate  > 
                    <   asp:Button    运行  ="  文本   PostBackFirst "  ID    btnPostF" 
 
                     span>                            onclick   ="  btnPostF_Click" > 
                    <   asp:Button    运行  ="  文本   PostBackSecond "  ID    btnPostS" 
                     span>                            onclick   ="  btnPostS_Click" > 
                    <   asp:Button    运行  ="  文本   AbortPostBack "  ID    btnAbort" 
                     span>                            OnClientClick   ="  > 
                    <   asp:Label     ID   ="   runat   服务器" 文本  " <   asp:Label     ID   ="   runat   服务器" 文本  " <  /contenttemplate  > 
            
    <  /form  > 
<  /body  >  




 受保护的  void  btnPostF_Click(对象发​​件人,EventArgs e)
       {
           System.Threading.Thread.Sleep( 4000 );
           Label1.Text = " ;

       }

       受保护的 无效 btnPostS_Click(对象发​​件人,EventArgs e)
       {
           System.Threading.Thread.Sleep( 4000 );
           Label2.Text = " ;

       }

解决方案

我认为两个标签的autopostback = true都可以正常工作. />
事情表现正常.让我解释一下它是如何工作的-

假设您单击第一个按钮,则单击事件是单击事件,它休眠4秒钟.现在,如果您在睡眠状态下通过单击第三个按钮来中止帖子,则可以.然后它将不会继续进行该事件.如果等待4秒钟,则可以看到标签已更新为所需的值.与第二个按钮相同.


I use an UpdatePanel with some controls. When I click on the button, it creates a sleep. In this time I click on second button, its handlers execute async successfully. But one of the labels does not get updated. Why?

<body>
    <form id="form1"  runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        
        <asp:UpdatePanel ChildrenAsTriggers="true" ID="UpdatePanel1"  runat="server" >
            <contenttemplate>
                    <asp:Button runat="server" Text="PostBackFirst" ID="btnPostF" 

                        onclick="btnPostF_Click"/> 
                    <asp:Button runat="server" Text="PostBackSecond" ID="btnPostS"

                        onclick="btnPostS_Click"/> 
                    <asp:Button runat="server" Text="AbortPostBack" ID="btnAbort"

                        OnClientClick="Sys.WebForms.PageRequestManager.getInstance().abortPostBack();
                        alert('Postback Cancelled');"/>
                    <asp:Label ID="Label1" runat="server" Text="">            
                    <asp:Label ID="Label2" runat="server" Text="">            
            </contenttemplate>
            
    </form>
</body>




protected void btnPostF_Click(object sender, EventArgs e)
       {
           System.Threading.Thread.Sleep(4000);
           Label1.Text = "PostBack 1 Completed";

       }

       protected void btnPostS_Click(object sender, EventArgs e)
       {
           System.Threading.Thread.Sleep(4000);
           Label2.Text = "PostBack 2 Completed";

       }

解决方案

i think autopostback=true for the two labels will work fine..


Hi,

Things are behaving correctly. Let me explain how it is working-

Suppose you click on the first button, on click it comes to the click event and it sleeps for 4 seconds. Now while its in sleep if you abort the post back by clicking third button. Then it will not proceed with the event. If you wait for 4 second then you can see the label is updated with the desired value. Same with second button.


这篇关于UpdatePanel中的控件未更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆