ModalPopUp不隐藏按钮点击
本文关键字:按钮 隐藏 ModalPopUp | 更新日期: 2023-09-27 18:17:24
使用RadioButtonList来选择输入数据的选项,其中之一是AJAX ModalPopUp中的gridview。当用户单击ModalPopUp中的按钮时,ModalPopUp需要隐藏。在这一点不起作用,尽管它在一个点上。代码如下所示。我认为这是一件简单的事情,我忽略了,但我已经看过很多其他的帖子,没有成功:
RadioButtonList:
<asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged">
<asp:ListItem Selected="True">Manual Entry (separate with semi-colons)</asp:ListItem>
<asp:ListItem>Artists Only</asp:ListItem>
<asp:ListItem>Clients Only</asp:ListItem>
<asp:ListItem>Test with a gridview</asp:ListItem>
</asp:RadioButtonList>
Gridview in ModalPopUp:
<asp:UpdatePanel runat="server">
<ContentTemplate>
<asp:HiddenField runat="server" ID="ModalHidden" />
<ajax:ModalPopupExtender ID="George" runat="server" TargetControlID="ModalHidden" PopupControlID="PopUpPanel" DropShadow="true" CancelControlID="btnCancel" PopupDragHandleControlID="Select Emails" Drag="true">
</ajax:ModalPopupExtender>
<br>
</br>
<br>
</br>
<asp:Panel ID="PopUpPanel" runat="server" BorderColor="Black" BackColor="LightGray" BorderStyle="Solid" BorderWidth="10px">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="Id" DataSourceID="SqlDataSource3">
<rowstyle backcolor="LightCyan" forecolor="DarkBlue" font-italic="true"/>
<alternatingrowstyle backcolor="PaleTurquoise" forecolor="DarkBlue" font-italic="true"/>
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="ckboxGridview" runat="server"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Id" HeaderText="Id" ReadOnly="True" SortExpression="Id" Visible="false"/>
<asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" />
<asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" />
<asp:BoundField DataField="EmailAddress" HeaderText="EmailAddress" SortExpression="EmailAddress" />
</Columns>
</asp:GridView>
<br>
</br>
<asp:Button ID="btnSelectGVAddresses" runat="server" Text="Select Addresses" OnClick="btnOK_Click" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" />
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:C:'........ %>" SelectCommand="SELECT * FROM [tbl_Op_Recipients]"></asp:SqlDataSource>
</asp:Panel>
<br>
</br>
</ContentTemplate>
</asp:UpdatePanel>
RadioButtonList的后台代码:
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
{
TextBox temp_sent = frmSendEmail.FindControl("sent_toTextBox") as TextBox;
RadioButtonList temp_radio = frmSendEmail.FindControl("RadioButtonList1")
as RadioButtonList;
if (temp_radio.SelectedItem.Text == "Artists Only")
{
temp_sent.Text = "All Artists";
frmSendEmail.FindControl("EmailAddressesForEmail").Visible = false;
frmSendEmail.FindControl("PopUpPanel").Visible = false;
string sqlquery = @"SELECT EmailAddress, ISNULL(FirstName, 'Artist') AS EmailName FROM tbl_Op_Recipients WHERE EmailAddress IS NOT NULL AND UserType = 'A'";
gather_emails(sqlquery);
}
if (temp_radio.SelectedItem.Text == "Clients Only")
{
temp_sent.Text = "All Clients";
frmSendEmail.FindControl("EmailAddressesForEmail").Visible = false;
frmSendEmail.FindControl("PopUpPanel").Visible = false;
string sqlquery = @"SELECT EmailAddress, ISNULL(FirstName, 'Client') AS EmailName FROM tbl_Op_Recipients WHERE EmailAddress IS NOT NULL AND UserType = 'C'";
gather_emails(sqlquery);
}
if (temp_radio.SelectedItem.Text == "Manual Entry (separate with semi-colons)")
{
frmSendEmail.FindControl("EmailAddressesForEmail").Visible = true;
temp_sent.Text = "Enter Names and Emails Manually";
frmSendEmail.FindControl("PopUpPanel").Visible = false;
}
if (temp_radio.SelectedItem.Text == "Test with a gridview")
{
temp_sent.Text = "Select multiple items from popup";
frmSendEmail.FindControl("EmailAddressesForEmail").Visible = false;
frmSendEmail.FindControl("PopUpPanel").Visible = true;
ModalPopupExtender test = frmSendEmail.FindControl("George") as ModalPopupExtender;
test.Show();
Response.Write("breakpoint 291");
}
if (temp_radio.SelectedItem.Text == null )
temp_radio.Text = "";
}
Gridview (hide modalpopup)的代码:
protected void btnOK_Click(object sender, EventArgs e)
{
Panel PanelTemp = frmSendEmail.FindControl("PopUpPanel") as Panel;
PanelTemp.Visible = false;
RadioButtonList tempRadioButton = frmSendEmail.FindControl("RadioButtonList1") as RadioButtonList;
tempRadioButton.Items[0].Selected = true;
ModalPopupExtender PopUpTemp = frmSendEmail.FindControl("George") as ModalPopupExtender;
PopUpTemp.Hide();
GridView GVTemp = frmSendEmail.FindControl("Gridview1") as GridView;
var list = new List<EmailAddresses>();
foreach(GridViewRow row in GVTemp.Rows)
{
CheckBox ChkBoxtmp = row.FindControl("ckboxGridview") as CheckBox;
if(ChkBoxtmp.Checked)
{
list.Add(new EmailAddresses { EmailAddress = row.Cells[4].Text, FirstNames = row.Cells[2].Text });
}
}
EmailAddresses[] allRecords = list.ToArray();
btnSend_Click(allRecords);
}
我们在实现ajax弹出窗口时遇到了几个问题。最后,我们实现了一个不需要ajax/javascript/jquery/update panel/css技巧的解决方案。这已经为我们工作了大约一个月左右。你可能想看一下:使用ajax,更新面板,jquery或javascript的模态弹出-令人惊讶的是,这似乎工作
谢谢
我添加了一个下载源代码的链接,供任何人尝试。http://02e34b5.netsolhost.com/youtube/Zpopup.aspx由于