【问题标题】:Open single pop up from two different buttons从两个不同的按钮打开单个弹出窗口
【发布时间】:2023-03-14 05:07:01
【问题描述】:

我有两个不同的按钮,即保存和更新。我想为两个按钮打开一个弹出窗口,那我该怎么做。?此外,如果弹出窗口在保存按钮单击时打开,那么当它关闭时,它应该指向 OnClick_save() 按钮事件,如果它是从更新按钮打开的,在弹出窗口关闭时,它应该指向 OnClick_Update()按钮点击事件。

我该怎么做? 这是我的代码

<tr>
<td>
<table id="tblButton" runat="server">
   <tr>
       <td>
            <asp:Button ID="btnAdd" runat="server" Text="Add" Visible="false"  />
      &nbsp;<asp:Button ID="btnUpdate" runat="server" Text="Update" Visible="false" />&nbsp;<asp:Button ID="btnDelete" runat="server" Text="Delete" Visible="false" />
      &nbsp;<asp:Button ID="btnTargetButton" runat="server" Text="PopUpTarget" Visible="false" />
       </td>
   </tr>
 </table>
</td>
            </tr>
        </table>
    </td>
</tr>
<cc1:ModalPopupExtender ID="ModalPopupExtenderSave" runat="server"    TargetControlID="btnTargetButton" PopupControlID="passwordPopUp" DropShadow="true"   PopupDragHandleControlID="header" BackgroundCssClass="modalBackground" BehaviorID="ModalPopupExtenderSave" />

</table>
<asp:Panel ID="passwordPopUp" runat="server" Style="display: none; padding: 10px;
border: 1px; border-style: solid;" BackColor="#91C83B" Width="300px"   HorizontalAlign="Center"
BorderStyle="Solid" BorderWidth="5px">
<table class="TABLE100">
    <tr>
        <td colspan="3">
            <h3 style="text-align: center;" id="header">
                Confirm Password</h3>
        </td>
    </tr>
    <tr>
        <td colspan="3">
            &nbsp;
        </td>
    </tr>
    <tr>
        <td>
            &nbsp;
        </td>
        <td width="50px">
            <asp:Label ID="lblPasswrd" runat="server" Text="Password" Font-Bold="True" Font-Size="Larger"></asp:Label>
        </td>
        <td>
            <asp:TextBox ID="txtPassword" runat="server" SkinID="TextBoxLong"></asp:TextBox>
        </td>
    </tr>
    <tr>
        <td>
            &nbsp;
        </td>
        <td>
            &nbsp;
        </td>
        <td>
            &nbsp;
        </td>
    </tr>
    <tr>
        <td>
            &nbsp;
        </td>
        <td>
            &nbsp;
        </td>
        <td>
            <asp:Button ID="btnSubmit" runat="server" Text="SUBMIT" Width="70px" OnClick="btnSubmit_Click"/>
        </td>
    </tr>
</table>
</asp:Panel>

我在一定程度上解决了这个问题的一些方法。 现在的问题是三个不同的按钮,即。插入、更新和删除按钮负责打开弹出窗口,然后打开一个 ASP:面板,该面板包含提交按钮。那么在提交按钮上,我能知道哪个按钮负责打开面板吗????

【问题讨论】:

    标签: asp.net ajax modalpopupextender


    【解决方案1】:

    您可以将隐藏按钮用作模式弹出窗口的Okbutton,然后从代码中调用按钮OnClick。保存和更新按钮。

    【讨论】:

    • 因为你的btnTargetButton 是隐藏的,让我们在你的 btnSubmit_Click 中说你做所有的逻辑,当你需要调用 MPE(模态弹出扩展器)时,你只需调用 @987654322 @ 并在该按钮的 Click 处理程序中调用 MPE,例如 MPE.show(),然后在完成所有预期工作后编写 MPE.hide() 并关闭 Modal Popup。
    • ..但是在提交事件上我想做插入、更新和删除。所以在每次操作之前我都需要打开弹窗输入密码。如果密码正确,那么只有这样才能进行操作。以及如何知道在特定时刻要执行哪个操作。???如果可能,请提供代码...
    • btnSubmit_Click(object sender, EventArgs e) { //some code ........ ........ //befor insert //call popup like popup.show(); } //In your popup you enter login/password and press submit btnSubmit_Click(...) { if(validUser) insert(); : : //after doing intended opration just call popup.hide(); } 删除也可以实现,更新希望对你有帮助...:)
    • ..每次插入、更新和删除都会调用 3 次弹出窗口。验证用户后,我需要单击 btnSubmit。那么如何知道按钮 btnSubmit 是否被单击以进行插入、更新或删除?这里单个按钮负责所有三个操作。
    • 使用 字段 保存调用此弹出窗口的按钮的值/名称,然后在模态弹出窗口中使用此字段,如 if(field == "insert") insertData(); else if(field == "delete") deleteData(); else if(field == "Update") UpdateData(); 在您将存储的字段中您希望在 btnInsert(.....) field = "insert;" 上进行的操作的名称 like
    【解决方案2】:

    为每个按钮单击添加服务器端事件处理程序。使用 jquery 显示每个按钮的弹出窗口,即来自 jquery 的 $('#button1').click$('#button2').click

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-12
      • 2022-05-23
      • 2018-12-18
      • 2012-02-17
      • 1970-01-01
      相关资源
      最近更新 更多