如何在javascript函数中触发的UpdatePanel [英] how to trigger updatepanel within a javascript function

查看:117
本文介绍了如何在javascript函数中触发的UpdatePanel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的asp.net网页一个UpdatePanel。我想用一个按钮触发一个javascript函数INSEAD内触发的UpdatePanel。结果
为了做到这一点,我用 __ doPostBack('myUpdatePanel',''); 功能。但我认为它会导致整个页面回发。当我把这个功能也执行我的document.ready功能。我可能会丢失一些要点。结果
是否有任何其他的方式来javascript函数中触发的UpdatePanel?

i have an updatepanel in my asp.net web page. I want to trigger the updatepanel within a javascript function insead of triggering with a button.
In order to do that, i used __doPostBack('myUpdatePanel', ''); function. But i think it causes the whole page postback. My document.ready function is also executed when i call this function. I may be missing some points.
Is there any other way to trigger updatepanel within a javascript function?

推荐答案

我想,如果你把更新面板内隐藏的按钮,你可以使用JavaScript来触发此按钮的点击,它会做你想要什么。

I think if you put a hidden button inside the update panel and you can use the javascript to fire the click of this button, it will do what you want.

<script type="text/javascript">
        function Update_UpdatePaanel() {
            document.getElementById('<%= YourButton.ClientID %>').click()
        }
    </script>

按钮必须是一个隐藏分区里面没有设置=看得到假,因为如果你把它设置为false,控制将不会呈现和JavaScript会产生错误。

The button MUST be inside a hidden div and DON'T set visibile="false" because if you set it to false, the control will not render and the javascript will produce errors.

<div style="display:none">
        <asp:Button ID="YourButton" runat="server" />
    </div>

这篇关于如何在javascript函数中触发的UpdatePanel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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