首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何在ASP.Net中单击按钮时显示/隐藏面板

如何在ASP.Net中单击按钮时显示/隐藏面板
EN

Stack Overflow用户
提问于 2014-01-14 04:25:05
回答 1查看 13.3K关注 0票数 0

我有问题显示或隐藏一个面板的按钮点击。默认情况下,面板是隐藏的,但我希望面板在按钮被单击后显示出来,但它现在对我不起作用。

只有当另一个回发发生时,面板才会出现,比如当我选择下拉并触发回发时,我的面板就会显示出来。我认为问题是我使用的是一个UpdatePanel,它只做了部分回发。

这是我在控件(按钮)中使用AsyncPostBackTrigger的代码。

<div id="dvGrid" style="padding: 10px; width: 876px">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
               <asp:GridView ID="GridView1" runat="server" Width="870px" OnRowDataBound="RowDataBound"
                    AutoGenerateColumns="False" Font-Names="Arial" Font-Size="11pt" AlternatingRowStyle-BackColor="#C2D69B"
                    HeaderStyle-BackColor="green" ShowFooter="True" OnPageIndexChanging="OnPaging"
                    DataKeyNames="DEV_SK">
                    <AlternatingRowStyle BackColor="#C2D69B" />
                    <Columns> 
                       <asp:TemplateField ItemStyle-Width="30px" HeaderText="ID" Visible = "false">
                            <ItemTemplate>
                                <asp:Label ID="lblDEV_SK" runat="server" Text='<%# Eval("DEV_SK")%>'></asp:Label>
                            </ItemTemplate>
                            <ItemStyle Width="10px" />
                        </asp:TemplateField>
                </asp:GridView>
             </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="btnUpdate"  />
            </Triggers>
        </asp:UpdatePanel>  
    </div>

下面是按钮的代码:

<asp:Button ID="btnUpdate" runat="server" Text="SAVE" OnClick = "Update" Visible = "true" 
Font-Bold="False" Font-Size="Large" Height="30px" Width="157px"/>

这是他们点击按钮后的代码:

 protected void Update(object sender, EventArgs e)
    {
        Panel1.Visible = true;
        //do somthing else

    }

下面是我的小组讨论:

   <div>
       <asp:Panel ID="Panel1" runat="server" BorderStyle="Groove" Height="109px" Visible="false"
            Width="870px" BackColor="#FFFFE1">
            <asp:Label ID="Label2" runat="server" Text="SIGN" Font-Bold="True" 
                ForeColor="#FF3300"></asp:Label>
            <br />
            <br />

            <asp:Label ID="lblUID" runat="server" Text="User ID:"></asp:Label>
            <asp:TextBox ID="txtUID" runat="server" Height="22px" Width="145px"></asp:TextBox> &nbsp;&nbsp;
            &nbsp;&nbsp;

            <asp:Label ID="lblPass" runat="server" Text="Password:"></asp:Label>
            <asp:TextBox ID="txtPass" runat="server" Height="23px" TextMode="Password" style="margin-top: 0px"></asp:TextBox>
            <br />
            <br />
            &nbsp;<asp:Button ID="btnSubmit" runat="server" Text="Submit" Width="183px"
                onclick="btnSubmit_Click" 
                OnClientClick="return confirm('Are you sure you want to submit?');" 
                Font-Bold="False" Font-Size="Medium" Height="30px" 
                style="margin-right: 1px" />
            <br />
        </asp:Panel>

    </div>
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21100696

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档