我有问题显示或隐藏一个面板的按钮点击。默认情况下,面板是隐藏的,但我希望面板在按钮被单击后显示出来,但它现在对我不起作用。
只有当另一个回发发生时,面板才会出现,比如当我选择下拉并触发回发时,我的面板就会显示出来。我认为问题是我使用的是一个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>
<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 />
<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>
https://stackoverflow.com/questions/21100696
复制相似问题