0

单击gridview中的一行时,我想制作一个ModalPopupExtender。我花了很多时间。但没有成功。

有直接的方法吗?如果是的话,有人可以给我一个示例代码..

我认识到 ModalPopupExtender 需要一个按钮来执行。所以我试图在一个按钮中触发点击方法并弹出我的窗口..

但我收到以下错误消息。

"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>

模态弹出扩展器

<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();
    }
4

1 回答 1

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;
        }
    }
于 2013-06-24T11:49:50.007 回答