在更新面板内部的单击按钮上隐藏更新面板外部的按钮 [英] hide button which is outside of update panel on the click of button which is inside of update panel

查看:91
本文介绍了在更新面板内部的单击按钮上隐藏更新面板外部的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<asp:ScriptManager ID="ScriptManager1" runat="server">
   </asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
   <ContentTemplate>
       <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
   </ContentTemplate>
   </asp:UpdatePanel>
       <asp:Button ID="Button2" CssClass="btnclas" runat="server" Text="Button" />





这是我的代码:

aspx页面上的脚本:



This is my code :
Script on aspx page:

<script type="text/javascript">
    function ShowHide() {
        $('.btnclas').attr("style", "display:none");
    }
</script>





Code Behind:



Code Behind:

protected void Button1_Click(object sender, EventArgs e)
        {
            Page.RegisterStartupScript("js", "<script language=JavaScript>ShowHide();</script>");
        }







我想在点击Button1后隐藏代码背面的Button2在更新面板内。如果我评论更新面板然后它工作正常,但我希望这与更新面板。




I want to hide Button2 from code behind on the click of Button1 which is inside of update panel. If I comment update panel then it is working fine, but i want this with update panel.

推荐答案

('。btnclas')。attr(style,显示:无);
}
< / script >
('.btnclas').attr("style", "display:none"); } </script>





Code Behind:



Code Behind:

protected void Button1_Click(object sender, EventArgs e)
        {
            Page.RegisterStartupScript("js", "<script language=JavaScript>ShowHide();</script>");
        }







我想在点击Button1后隐藏代码背面的Button2在更新面板内。如果我评论更新面板然后它工作正常,但我希望这与更新面板。




I want to hide Button2 from code behind on the click of Button1 which is inside of update panel. If I comment update panel then it is working fine, but i want this with update panel.


为了反映button2的状态,该区域或页面需要重新加载。您可以在更新面板中同时使用Button1和Button2,或者您必须允许使用button1进行完整回发。



您需要允许Button1完全回发。在UpdatePanel中添加以下代码。



In order to reflect the state of button2, That area or Page needs to reload. You can have Button1 and Button2 both in the update panel or you have to allow a full postback with button1

You need to allow full postback for Button1. Add below code in your UpdatePanel.

<Triggers>
       <asp:PostBackTrigger ControlID="Button1" />
   </Triggers>





因为更新面板赢了不允许完全回发,更新面板内的操作不会影响外部区域。



Because Update panel won't allow to full postback and actions inside the updatepanel won't affect the outside areas.


这篇关于在更新面板内部的单击按钮上隐藏更新面板外部的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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