Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ajax 多重更新面板_Ajax_Updatepanel_Dopostback - Fatal编程技术网

Ajax 多重更新面板

Ajax 多重更新面板,ajax,updatepanel,dopostback,Ajax,Updatepanel,Dopostback,我只是从stackoverflow开始,至少作为一名作家。。。 我非常感谢您在我遇到的有关AJAX的一些问题上提供的帮助。 首先,我以前在工作中实现过AJAX,但只在一些基本的东西上实现过,比如通过点击按钮刷新的UpdatePanel。但是现在我需要实现多个UpdatePanel,它们通过多种方式刷新 我简化了HTML代码,但基本上看起来像: <script type="text/javascript"> function mostrarDatosSolicitante()

我只是从stackoverflow开始,至少作为一名作家。。。 我非常感谢您在我遇到的有关AJAX的一些问题上提供的帮助。 首先,我以前在工作中实现过AJAX,但只在一些基本的东西上实现过,比如通过点击按钮刷新的UpdatePanel。但是现在我需要实现多个UpdatePanel,它们通过多种方式刷新

我简化了HTML代码,但基本上看起来像:

<script type="text/javascript">
    function mostrarDatosSolicitante() {
        var nroDoc = document.getElementById('<%=txtDocumento.ClientID%>').value;

        if (nroDoc != "") {
            __doPostBack('<%=up1.ClientID%>', '');
        }
    }        
</script>
<table>
    <tr>
        <td>
            <b>Documento </b>
        </td>
        <td>
            <asp:TextBox runat="server" id="txtDoc" 
                         onblur="mostrarDatosSolicitante()"/>                    
        </td>
        <td>
            <asp:Button runat="server" id="btnConfirmar" 
                        Text="Confirmar" />
        </td>
    </tr>            
</table>
<asp:ScriptManager ID="ScriptManager1" runat="server" 
                   EnablePartialRendering="True" />
    <asp:UpdatePanel ID="up1" runat="server" 
                     OnLoad="refreshUP1" UpdateMode="Conditional">            
        <ContentTemplate>

            <!--some stuff-->

        </ContentTemplate>
    </asp:UpdatePanel>
    <asp:UpdatePanel ID="up2" runat="server" 
                     OnLoad="refreshUP2" UpdateMode="Conditional">
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnConfirmar" />
        </Triggers>
        <ContentTemplate>  

                <!--some stuff 2-->

            <asp:UpdatePanel ID="up3" runat="server" 
                             OnLoad="refreshUP3" UpdateMode="Conditional">
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="ddlTipoConvInt" />
                </Triggers>
                <ContentTemplate>

                    <!--some stuff 3-->

                </ContentTemplate>
            </asp:UpdatePanel>

        </ContentTemplate>
    </asp:UpdatePanel>
</div>
protected void refreshUP1(object sender, EventArgs e)
{
    //do something
}
protected void refreshUP2(object sender, EventArgs e)
{
    //do something
}
protected void refreshUP3(object sender, EventArgs e)
{
    //do something
}
我需要解决的问题是,当我离开文本框时,会触发javascript刷新updatepanel up1并触发“refreshUP1”方法。但在我的例子中,所有的UpdatePanel都在刷新,至少运行了“refreshUP2”和“refreshUP3”方法,导致了不希望出现的行为

欢迎任何方式

这是由OnLoad事件引起的

您必须理解,无论回发是异步的,页面上的所有控件都会被加载并经历一个生命周期。基本上,UpdatePanel的区别在于,AsyncPostBack页面上只返回它的内容

有关更多信息,您可以查看以下内容:

要执行您想要执行的操作,您不应该将刷新SUB链接到OnLoad事件。我经常使用的解决方案是将它们中的每一个链接到我设置为AsyncPostBackTrigger的隐藏按钮的click事件