模态弹出扩展器问题

时间:2010-12-14 11:53:11

标签: c# javascript asp.net ajax ajaxcontroltoolkit

我使用模态弹出扩展器在另一个单独的窗口中显示我的详细信息它是一个面板包含一些控件问题是:: 当我点击我的按钮,其中包含:: show()方法刚刚冻结的父页面,另一边根本没有弹出窗口我有一个网格视图当我点击它上面的最后一个按钮弹出窗口时,网格视图上的其他按钮产生相同的行为我的第一个按钮,我不知道我的面板可见性=真的问题是什么,我的后面的代码没有设置..我查看源代码,我找到面板及其内容然后为什么弹出窗口不出现..我搜索很多但是我没有找到解决问题的方法.. 我的aspx ::

<asp:Panel id="master_editMode"  runat="server"  >                    
                 <div id="masterDiv" style="width:98%"  dir="rtl">
                    <div id="masterControls"  align="center">
                    <table border="0" width="98%">


                        <tr>
                            <td align="center" dir="rtl">
                                <asp:ObjectDataSource ID="ObjDS_AllTasks" runat="server" 
                                    SelectMethod="Get_All_Tasks" TypeName="DocumentFlowModuleDTO.TaskDTO">
                                </asp:ObjectDataSource>
                                <asp:HiddenField ID="hd_Task_Code" runat="server" />
                                <table>
                                    <tr>
                                        <td>
                                            <asp:Label ID="Label11" runat="server" Text="Search for Task" Visible="False"></asp:Label>
                                        </td>
                                        <td align="right">
                                            <asp:TextBox ID="txt_Search" runat="server" AutoPostBack="True" 
                                                ontextchanged="txt_Search_TextChanged" Width="200px" Visible="False"></asp:TextBox>
                                        </td>
                                        <td>
                                            &nbsp;</td>
                                    </tr>
                                    <tr>
                                        <td colspan="3">


                                            <asp:GridView ID="grd_AllTasks" runat="server" AllowPaging="True" 
                                                AutoGenerateColumns="False" CssClass="Alternating" DataKeyNames="task_code" 
                                                DataSourceID="ObjDS_AllTasks" 
                                                onpageindexchanging="grd_AllTasks_PageIndexChanging" 
                                                onrowdatabound="grd_AllTasks_RowDataBound" style="margin-right: 0px">
                                                <RowStyle VerticalAlign="Top" />

                                                    HeaderText="ÍÐÝ">
                                                        <ItemTemplate>
                                                            <asp:ImageButton ID="btn_Delete_Task" runat="server" 
                                                                CommandArgument="<%# Bind('task_code') %>" Height="33px" 
                                                                ImageUrl="~/Images/delete.png" oncommand="btn_Delete_Task_Command" 
                                                                Width="67px" />
                                                            <cc1:ConfirmButtonExtender ID="btn_Delete_Task_ConfirmButtonExtender" 
                                                                runat="server" ConfirmText="åá ÊÑíÏ ÍÐÝ æËíÞÉ ÇáÇÚÊãÇÏ ¿" Enabled="True" 
                                                                TargetControlID="btn_Delete_Task">
                                                            </cc1:ConfirmButtonExtender>
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                </Columns>
                                                <HeaderStyle HorizontalAlign="Right" />
                                            </asp:GridView>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td align="right" dir="rtl">
                                <asp:Label ID="lbl_TaskName" runat="server" Font-Bold="True" Font-Size="13pt"></asp:Label>
                            </td>
                        </tr>
                        <tr>
                            <td align="center" dir="rtl" style="height: 196px">
                                <table>
                                    <tr>
                                        <td align="left">
                                            <asp:Label ID="lbl_No_States" runat="server" Font-Bold="True" ForeColor="Red"></asp:Label>
                                        </td>
                                        <td align="right">
                                            <asp:ImageButton ID="btn_AddStatesToTask" runat="server" 
                                                ImageUrl="Images/add.png" onclick="btn_AddStatesToTask_Click" Visible="False" />

                                            <asp:Button ID="Dummy_btn2" runat="server" Text="Button" Style="display:none;" /> 
                                            <cc1:ModalPopupExtender ID="btn_AddStatesToTask_ModalPopupExtender" 
                                                runat="server" 
                                                TargetControlID="Dummy_btn2"
                                                BackgroundCssClass="modalBackground" 
                                                PopupControlID="pnl_Add_States"
                                                DropShadow="True">
                                            </cc1:ModalPopupExtender>
                                        </td>
                                    </tr>
                                </table>
                                <asp:HiddenField ID="hd_StateSerial" runat="server" />
                                <asp:HiddenField ID="hd_StateRowIndex" runat="server" />
                                <asp:GridView ID="grd_States" runat="server" AllowPaging="True" DataKeyNames="state_serial" 
                                    onpageindexchanging="grd_States_PageIndexChanging" Visible="False" 
                                    CssClass="Alternating" AutoGenerateColumns="False">
                                    <Columns>
                                        <asp:BoundField DataField="state_name" HeaderText="ÇáãÑÍáÉ" 
                                            ShowHeader="False" />
                                        <asp:BoundField DataField="state_order" HeaderText="ÊÑÊíÈ ÇáãÑÍáÉ" 
                                            ShowHeader="False" />
                                        <asp:TemplateField HeaderText="Power" ShowHeader="False">
                                            <EditItemTemplate>
                                                <asp:CheckBox ID="CheckBox1" runat="server" />
                                            </EditItemTemplate>
                                            <ItemTemplate>
                                                <asp:CheckBox ID="chb_StatePower" runat="server" 
                                                    Checked='<%# Convert.ToBoolean(Eval("power_flag")) %>' Enabled="False" />
                                            </ItemTemplate>
                                            <ItemStyle Width="40px" />
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="New" ShowHeader="False">
                                            <EditItemTemplate>
                                                <asp:CheckBox ID="CheckBox3" runat="server" />


                                                <asp:Button ID="Dummy_btn4" runat="server" Text="Button" Style="display:none;" />

                                                            <cc1:ModalPopupExtender ID="btn_TaskState_Edit_ModalPopupExtender" runat="server"
                                                            TargetControlID="Dummy_btn4"
                                                            BackgroundCssClass="modalBackground" 
                                                            PopupControlID="pnl_Add_States"
                                                            DropShadow="True">
                                                            </cc1:ModalPopupExtender>

                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="ÍÐÝ" ShowHeader="False">
                                            <ItemTemplate>
                                                <asp:ImageButton ID="btn_TaskState_Delete" runat="server" 
                                                    CommandArgument="<%# Bind('state_serial') %>" Height="26px" 
                                                    ImageUrl="~/Images/delete.png" oncommand="btn_TaskState_Delete_Command" 
                                                    Width="47px" />
                                                <cc1:ConfirmButtonExtender ID="btn_TaskState_Delete_ConfirmButtonExtender" 
                                                    runat="server" ConfirmText="åá ÊÑíÏ ÍÐÝ ÇáãÑÍáÉ ¿" Enabled="True" 
                                                    TargetControlID="btn_TaskState_Delete">
                                                </cc1:ConfirmButtonExtender>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                </asp:GridView>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:ObjectDataSource ID="ObjectDataSource_States" runat="server" 
                                    SelectMethod="Select_TaskStates" TypeName="DocumentFlowModule.DTO.TaskStateDTO">
                                    <SelectParameters>
                                        <asp:Parameter Name="task_code" Type="Int32" />
                                    </SelectParameters>
                                </asp:ObjectDataSource>
                            </td>
                        </tr>
                    </table>
                    </div>
                </div>
            </asp:Panel>


        <asp:Panel ID="pnl_Add_Task" runat="server" CssClass="modalPopup"><%-- Style="display:none;"--%>
          <div id="div3" style="width: 95%">
                <div id="div4" align="center">
                    <table>
                        <tr>
                        <td>
                            <asp:UpdatePanel ID="UpPnl1" runat="server">
                                <ContentTemplate> 
                                    <table dir="rtl" style="text-align: right">
                                        <tr bgcolor="#f1ece2">
                                            <th align="right" height="35" valign="middle" colspan="3">
                                                <asp:Label ID="lbl_New_Task" runat="server" Font-Bold="False" Font-Size="14pt" 
                                                    Text="ÅÖÇÝÉ æËíÞÉ ÇÚÊãÇÏ" Visible="False"></asp:Label>
                                                <asp:Label ID="lbl_Edit_Task" runat="server" Font-Bold="False" Font-Size="14pt" 
                                                    Text="ÊÚÏíá æËíÞÉ ÇÚÊãÇÏ" Visible="False"></asp:Label>
                                            </th>
                                        </tr>
                                        <tr>
                                            <td class="title" width="160">

                                                <asp:Label ID="Label1" runat="server" Text="Task Name"></asp:Label>

                                            </td>
                                            <td style="width: 140px">

                                                <asp:TextBox ID="txt_TaskName" runat="server"></asp:TextBox>

                                            </td>
                                            <td>

                                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                                                    ControlToValidate="txt_TaskName" ErrorMessage="*" ValidationGroup="G1"></asp:RequiredFieldValidator>

                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="title" width="160">

                                                <asp:Label ID="Label10" runat="server" Text="DataBase Name"></asp:Label>

                                            </td>
                                            <td style="width: 140px">


                                                <asp:DropDownList ID="ddl_DataBases" runat="server" AutoPostBack="True" 
                                                    ondatabound="ddl_DataBases_DataBound" 
                                                    onselectedindexchanged="ddl_DataBases_SelectedIndexChanged">
                                                </asp:DropDownList>


                                            </td>
                                            <td>


                                                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                                                    ControlToValidate="ddl_DataBases" ErrorMessage="*" InitialValue="--Select--" 
                                                    ValidationGroup="G1"></asp:RequiredFieldValidator>


                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="title" width="160">

                                               <asp:Label ID="Label2" runat="server" Text="Table Name"></asp:Label>
                                            </td>
                                            <td style="width: 140px">
                                            <asp:DropDownList ID="ddl_Tables" runat="server" AutoPostBack="True" 
                                                            ondatabound="ddl_Tables_DataBound" 
                                                            onselectedindexchanged="ddl_Tables_SelectedIndexChanged">
                                                        </asp:DropDownList>

                                            </td>
                                            <td>
                                            <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
                                                            ControlToValidate="ddl_Tables" ErrorMessage="*" InitialValue="--Select--" 
                                                            ValidationGroup="G1"></asp:RequiredFieldValidator>
                                            </td>
                                        </tr>
                                        <tr>
                                                                    <td class="title" width="160">

                                                                        <asp:Label ID="Label17" runat="server" Text="Table Key"></asp:Label>

                                                                    </td>

                                                                    <td style="width: 140px">
                                                                        <asp:Label ID="lbl_Key" runat="server"></asp:Label>
                                                                        <asp:CheckBoxList ID="cbl_Columns" runat="server">
                                                                        </asp:CheckBoxList>
                                                                    </td>

                                                                    <td>

                                                                        <asp:Label ID="lbl_Select_Key" runat="server" ForeColor="Red"></asp:Label>

                                                                    </td>
                                                                </tr>

                                        <tr>
                                                                    <td class="title" width="160">

                                                                        <asp:Label ID="Label18" runat="server" Text="Current Record State"></asp:Label>

                                                                    </td>

                                                                    <td style="width: 140px">
                                                                        <asp:DropDownList ID="ddl_Columns" runat="server" AutoPostBack="True" 
                                                                            ondatabound="ddl_Columns_DataBound">
                                                                        </asp:DropDownList>
                                                                    </td>

                                                                    <td>

                                                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" 
                                                                            ControlToValidate="ddl_Columns" ErrorMessage="*" InitialValue="--Select--" 
                                                                            ValidationGroup="G1"></asp:RequiredFieldValidator>
                                                                    </td>
                                                                </tr>
                                        <tr>
                                            <td class="title" width="160">
                                                <asp:Label ID="Label5" runat="server" Text="Form View "></asp:Label>
                                            </td>
                                            <td style="width: 140px">
                                                <asp:TextBox ID="txt_F_View" runat="server"></asp:TextBox>
                                            </td>
                                            <td>
                                                <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" 
                                                    ControlToValidate="txt_F_View" ErrorMessage="*" InitialValue="--Select--" 
                                                    ValidationGroup="G1"></asp:RequiredFieldValidator>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="title" width="160">
                                                <asp:Label ID="Label6" runat="server" Text="Form New"></asp:Label>
                                            </td>

                                            </td>
                                        </tr>                                         

                          </table>
                 </ContentTemplate>

                </asp:UpdatePanel>
                </td>
                </tr>
                <tr>                                   
                                <td dir="rtl" align="center">
                                    <asp:ImageButton ID="btn_OK" runat="server" ImageUrl="~/Images/add.png" 
                                        onclick="btn_OK_Click" ValidationGroup="G1" Visible="False" />
                                    <asp:ImageButton ID="btn_Edit" runat="server" ImageUrl="~/Images/edit.png" 
                                        onclick="btn_Edit_Click" ValidationGroup="G1" Visible="False" />
                                    <asp:ImageButton ID="btn_Cancel_Task" runat="server" CausesValidation="False" 
                                        Height="36px" ImageUrl="~/Images/cancel.png" onclick="btn_Cancel_Task_Click" />
                                </td>
                            </tr>
               </table>


                </div>

                </div>
        </asp:Panel>

btn_add _task不会使我的弹出窗口显示为冻结父页面


我的.cs

protected void btn_Add_Task_Click(object sender, EventArgs e)
    {

        //AjaxControlToolkit.ModalPopupExtender modal1 = (AjaxControlToolkit.ModalPopupExtender) table1.FindControl("btn_Add_Task_ModalPopupExtender");
        //modal1.Show();

        grd_States.Visible = false;
        lbl_No_States.Text = "";
        btn_AddStatesToTask.Visible = false;
        lbl_TaskName.Text = "";

        //master_editMode.Visible = true;

        //pnl_Add_Task.Visible = true;

        btn_OK.Visible = true;
        btn_Edit.Visible = false;
        lbl_New_Task.Visible = true;
        lbl_Edit_Task.Visible = false;

        txt_TaskName.Text = "";
        ddl_DataBases.ClearSelection();
        ddl_Tables.Items.Clear();
        ddl_Columns.Items.Clear();
        cbl_Columns.Items.Clear();
        txt_F_New.Text = "";
        txt_F_View.Text = "";
        txt_Params.Text = "";
        txt_SP_Name.Text = "";

        btn_Add_Task_ModalPopupExtender.Show();

    }

提前致谢

EDITED ::

<table align="center" dir="rtl"> <tr> <td > <asp:Button ID="Dummy_btn" runat="server" Text="Button" Style="display:none;" />

                                                <asp:Button ID="btn_Add_Task"  runat="server" Text="ÅÖÇÝÉ æËíÞÉ ÇÚÊãÇÏ ÌÏíÏÉ" 
                                                    onclick="btn_Add_Task_Click" Font-Bold="True" Font-Size="12pt" 
                                                    ForeColor="#0066FF" />

                                                <cc1:ModalPopupExtender ID="btn_Add_Task_ModalPopupExtender" runat="server" 
                                                    TargetControlID="Dummy_btn"
                                                    PopupControlID="pnl_Add_Task"
                                                    BackgroundCssClass="modalBackground"
                                                    DropShadow="True" >

                                                </cc1:ModalPopupExtender>

                                            </td>
                                        </tr>
                                    </table>`

2 个答案:

答案 0 :(得分:1)

如果您希望在用户点击btn_Add_Task按钮时显示模态弹出窗口,则应将该按钮设置为扩展程序的TargetControlID

<cc1:ModalPopupExtender ID="btn_Add_Task_ModalPopupExtender" runat="server" 
    TargetControlID="btn_Add_Task" PopupControlID="pnl_Add_Task"
    BackgroundCssClass="modalBackground" DropShadow="True" />

在您当前的代码中,模式弹出窗口由名为Dummy_btn的按钮触发,我在您的标记中找不到,但可能不是您想要的。

答案 1 :(得分:1)

我们在ajax popup中遇到了很多问题。你可能想尝试我们过去一个月左右使用的方法,没有任何问题。这种方法创建了一个不需要ajax / jquery / javascript / css / update面板的弹出窗口。

这里: A modal popup with out using ajax, update panel, jquery or javascript- surprisingly this seems to work