我想在gridview中单击一行时制作一个make ModalPopupExtender。我花了很多时间。但没有成功。
有没有直接的方法呢?如果是,有人可以给我一个示例代码..
我认识到ModalPopupExtender需要一个按钮才能执行。所以我试图在一个按钮中触发click方法并弹出我的窗口..
但是我收到了以下错误消息。
"Error 43 'ASP.admin_creation_aspx' does not contain a definition for 'clickbtn' and no extension method 'clickbtn' accepting a first argument of type 'ASP.admin_creation_aspx' could be found (are you missing a using directive or an assembly reference?)"
以下代码是我试过的..
的JavaScript
> <script type="text/javascript">
>
> function clickbtn() {
>
> var myButton = document.getElementById('btnHidden');
> myButton.click();
> }
>
> </script>
ModalPopupExtender
<asp:ModalPopupExtender ID="InquiryPopupControlExtender" runat="server" TargetControlID="btnHidden" PopupControlID="InquiryPanel" CancelControlID="btn_InquiryBack" DropShadow="True" BackgroundCssClass="modalBackground" DynamicServicePath="" Enabled="True">
在GridView中grdInquiry_SelectedIndexChanged
protected void grdInquiry_SelectedIndexChanged(object sender, EventArgs e)
{
lbl_inqDateTime.Text = grdInquiry.Rows[grdInquiry.SelectedRow.RowIndex].Cells[9].Text;
lbl_inqUserName.Text = grdInquiry.Rows[grdInquiry.SelectedRow.RowIndex].Cells[1].Text;
lbl_InqNic.Text = grdInquiry.Rows[grdInquiry.SelectedRow.RowIndex].Cells[2].Text;
lbl_InqProduct.Text = grdInquiry.Rows[grdInquiry.SelectedRow.RowIndex].Cells[3].Text;
lbl_InqInquiryType.Text = grdInquiry.Rows[grdInquiry.SelectedRow.RowIndex].Cells[4].Text;
lb_InqFacilityNo.Text = grdInquiry.Rows[grdInquiry.SelectedRow.RowIndex].Cells[5].Text;
lbl_InqDescription.Text = grdInquiry.Rows[grdInquiry.SelectedRow.RowIndex].Cells[8].Text;
//lbl_InqFullName.Text = grdInquiry.Rows[grdInquiry.SelectedRow.RowIndex].Cells[0].Text;
lbl_InqEmail.Text = grdInquiry.Rows[grdInquiry.SelectedRow.RowIndex].Cells[7].Text;
lbl_InqTelephone.Text = grdInquiry.Rows[grdInquiry.SelectedRow.RowIndex].Cells[6].Text;
grdInquiry.Attributes.Add("onchange", "return clickbtn();");
}
按钮事件
protected void btnHidden_Click(object sender, EventArgs e)
{
InquiryPopupControlExtender.Show();
}
答案 0 :(得分:0)
这是我完成的方式
模态弹出
<%--========================== Modal Popup Starts =============================--%>
<ajaxToolKit:ModalPopupExtender ID="mpeDetails" runat="server" TargetControlID="btnPopDummyOpen"
PopupControlID="panelModalPopUp" CancelControlID="imgBtnPopupClose" BackgroundCssClass="modalBackground">
</ajaxToolKit:ModalPopupExtender>
<asp:Panel ID="panelModalPopUp" Style="display: none;" runat="server" Width="750px"
Height="450px" CssClass="modalBox">
<div style="border: 1px solid #6CC5CB;">
<div class="modalBoxCaption">
<div id="popuPHeaderLeft">
Print Bill
</div>
<div id="popuPHeaderRight">
<asp:ImageButton ID="imgBtnPopupClose" ImageUrl="~/Resources/Images/delete.png" runat="server" /></div>
</div>
<div>
<div id="popUpContent" style="margin: 0px; background-color: White; height: 380px;
overflow: auto; width: 100%;" runat="server">
</div>
<div style="height: 30px; padding: 5px 0px 5px 0px; background-color: White;" id="hide"
class="hide">
Your content goes here
</div>
</div>
</div>
<div style="display: none">
<asp:Button ID="btnPopDummyOpen" runat="server" />
</div>
</asp:Panel>
<%--========================== Modal Popup Ends =============================--%>
我的GridView(删除某些行会相应地修改
<asp:GridView ID="gridViewMaterialIn" runat="server" AutoGenerateColumns="false"
AllowPaging="true" OnPageIndexChanging="gridViewMaterialIn_PageIndexChanging"
OnRowCommand="gridViewMaterialIn_RowCommand" PageSize="15" OnRowEditing="gridViewMaterialIn_RowEditing"
OnRowDeleting="gridViewMaterialIn_RowDeleting" GridLines="None" Width="100%">
<Columns>
<asp:TemplateField ItemStyle-Width="10%" ItemStyle-HorizontalAlign="Center">
<HeaderTemplate>
<center>
Actions</center>
</HeaderTemplate>
<ItemTemplate>
<asp:ImageButton ID="imgBtnEdit" CommandName="Edit" ToolTip="Edit a record." CommandArgument='<%#Eval("MatInMain_Id") %>'
runat="server" ImageUrl="~/resources/Images/edit.png" />
<asp:ImageButton ToolTip="Delete a record." ID="imgBtnDelete" OnClientClick="return confirmDelete()"
CommandName="Delete" CommandArgument='<%#Eval("MatInMain_Id") %>' runat="server"
ImageUrl="~/resources/Images/delete.png" />
//======== On this button click i am opening my modal popup
<asp:ImageButton ToolTip="View & Print Bill." ID="ImageButtonViewDetails" CommandName="Print"
CommandArgument='<%#Eval("MatInMain_Id") %>' runat="server" ImageUrl="~/resources/Images/Print_Icon.png" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<center>
<b>No Data Found !!!</b></center>
</EmptyDataTemplate>
</asp:GridView>
背后的代码
//=-=-=-= Row command event for Edit, Delete
protected void gridViewMaterialIn_RowCommand(object sender, GridViewCommandEventArgs e)
{
switch (e.CommandName)
{
case "Edit":
Response.Redirect("MaterialInward.aspx?Mat=" + e.CommandArgument.ToString().Trim());
break;
case "Delete":
ClassMaterialInwardMain.deleteMaterialIn(Convert.ToInt32(e.CommandArgument));
bindMaterialIn();
break;
case "Print":
popUpContent.InnerHtml = ClassMaterialInwardMain.getPrintableMaterialIn(Convert.ToInt32(e.CommandArgument));
mpeDetails.Show();
break;
}
}