有人请帮忙。最近发现了Modalpopupextender并希望在我的gridview中使用它。我想在gridview中使用编辑链接按钮。单击时链接按钮应弹出Modalpopupextender。我现在的问题是,当我点击链接按钮时,Modalpopupextender不会弹出。以下是我的代码。
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Members.ascx.cs" Inherits="Debt.Members" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Panel ID="pnContainer" runat="server" Height="420px" Width="700px">
<style type="text/css">
.ModalBackground
{
background-color: Gray;
filter: alpha(opacity=60);
opacity: 0.6;
z-index: 10000;
}
.ModalPopup
{
background-color:White;
border-width:3px;
border-style:solid;
border-color:Gray;
padding:5px;
width: 350px;
height:210px;
}
</style>
<table style="width:100%;">
<tr>
<td>
</td>
<td>
WELCOME <asp:Label ID="lblUser" runat="server" Text="Label"></asp:Label>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:TextBox ID="txtSearch" runat="server" Height="24px" Width="623px"></asp:TextBox>
</td>
<td>
<asp:Button ID="btnSearch" runat="server" Text="Search"
onclick="btnSearch_Click" />
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
</table>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<table style="width:100%;">
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:GridView ID="gvContact" runat="server" AutoGenerateColumns="False" DataKeyNames="cid"
BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px"
CellPadding="3" EnableModelValidation="True" ForeColor="Black"
GridLines="Vertical">
<AlternatingRowStyle BackColor="#CCCCCC" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="btnLinkView" runat="server" onclick="btnLinkView_Click" Text="View"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="cid" HeaderText="Client ID" ReadOnly="true" />
<asp:BoundField DataField="regno" HeaderText="Reg No" />
<asp:BoundField DataField="name" HeaderText="Client Name" />
<asp:BoundField DataField="address" HeaderText="Client Address" />
<asp:BoundField DataField="city" HeaderText="City" />
<asp:BoundField DataField="state" HeaderText="State" />
<asp:BoundField DataField="website" HeaderText="Website" />
<asp:BoundField DataField="phone" HeaderText="Phone" />
<asp:BoundField DataField="email" HeaderText="Email" />
</Columns>
<FooterStyle BackColor="#CCCCCC" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
</asp:GridView>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
</table>
<asp:Panel ID="pnlAddEdit" runat="server" style="display:none;">
<asp:Label Font-Bold = "true" ID = "Label4" runat = "server" Text = "Customer Details" ></asp:Label>
<br />
<table align="center">
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text="Reg No"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtRegNo" Width = "40px" MaxLength = "5" runat="server"></asp:TextBox>
</td>
<td>
<asp:Label ID="Label2" runat="server" Text="Client Name"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtName" Width = "40px" MaxLength = "5" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label3" runat="server" Text="Address"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtAddress" Width = "40px" MaxLength = "5" runat="server"></asp:TextBox>
</td>
<td>
<asp:Label ID="Label5" runat="server" Text="City"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtCity" Width = "40px" MaxLength = "5" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label6" runat="server" Text="State"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtState" Width = "40px" MaxLength = "5" runat="server"></asp:TextBox>
</td>
<td>
<asp:Label ID="Label7" runat="server" Text="Website"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtWebsite" Width = "40px" MaxLength = "5" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label8" runat="server" Text="Email"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtEmail" Width = "40px" MaxLength = "5" runat="server"></asp:TextBox>
</td>
<td>
<asp:Label ID="Label9" runat="server" Text="Phone"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtPhone" Width = "40px" MaxLength = "5" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnClose" runat="server" Text="Close" OnClientClick = "return Hidepopup()"/>
</td>
<td>
<asp:Button ID="btnSave" runat="server" Text="Save" OnClick = "Save" />
</td>
</tr>
</table>
</asp:Panel>
<cc1:ModalPopupExtender ID="pnlAddEdit_ModalPopupExtender" runat="server"
DynamicServicePath="" Enabled="True" TargetControlID="btnControl" PopupControlID="pnlAddEdit"
BackgroundCssClass="ModalBackground" DropShadow="true" CancelControlID="btnClose">
</cc1:ModalPopupExtender>
<asp:Button ID="btnControl" runat="server" style="display:none" />
</ContentTemplate>
</asp:UpdatePanel>
<br />
</asp:Panel>
和我的btnLinkView_Click方法是。
protected void btnLinkView_Click(object sender, EventArgs e)
{
try
{
LinkButton btnLinkView = sender as LinkButton;
GridViewRow gvContactRow = (GridViewRow)btnLinkView.NamingContainer;
////.ReadOnly = true;
txtRegNo.Text = gvContactRow.Cells[1].Text.Trim();
txtName.Text = gvContactRow.Cells[2].Text.Trim();
txtAddress.Text = gvContactRow.Cells[3].Text.Trim();
txtCity.Text = gvContactRow.Cells[4].Text.Trim();
txtState.Text = gvContactRow.Cells[5].Text.Trim();
txtWebsite.Text = gvContactRow.Cells[6].Text.Trim();
txtPhone.Text = gvContactRow.Cells[7].Text.Trim();
txtEmail.Text = gvContactRow.Cells[8].Text.Trim();
pnlAddEdit_ModalPopupExtender.Show();
}
catch (Exception)
{ }
}
IT没有按预期弹出。感谢。