将 jQuery 对话框附加到 ASP.NET-MVC 中的“提交”按钮

发布于 2024-08-31 09:40:43 字数 753 浏览 3 评论 0原文

我有一个提交按钮,它一直在 ASP.NET-MVC 中提交我的表单。

我想将 jQuery 对话框附加到按钮单击。如果用户退出对话框,那么我也想退出提交。

我有对话框连接到其他按钮,但没有提交。我该怎么做?

****编辑****

这是我在另一个按钮上的对话框的示例。

<button type="button" id="create-company" >Create Company</button>

<div id="popupCreateService_Line" title="Create a new service line"> 
<fieldset>
    <label for="service_line_name">Name:</label>
    <%= Html.TextBox("service_line_name") %>

    <label for="service_line_desc">Desc:</label>
    <%= Html.TextBox("service_line_desc") %>

</fieldset>
</div>

$("#create-service_line").click(function() {
                $('#popupCreateService_Line').dialog('open');
            });

I have a submit button which has been working to submit my form in ASP.NET-MVC.

I would like to attach a jQuery dialog to the button click. If the user exits out of the dialog, then I would like to exit from the submit as well.

I have dialogs hooked to other buttons, but not submits. How can I do this?

****EDITED****

This is an example of the dialog I have on another button.

<button type="button" id="create-company" >Create Company</button>

<div id="popupCreateService_Line" title="Create a new service line"> 
<fieldset>
    <label for="service_line_name">Name:</label>
    <%= Html.TextBox("service_line_name") %>

    <label for="service_line_desc">Desc:</label>
    <%= Html.TextBox("service_line_desc") %>

</fieldset>
</div>

$("#create-service_line").click(function() {
                $('#popupCreateService_Line').dialog('open');
            });

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

近箐 2024-09-07 09:40:43

将其附加到您的表单加载事件。

  $(document).bind("keyup.EventPopupEvents", null, function(event)
{
    if (event.keyCode == 27)
    {
        ShutdownEditEventForm();
    }
});

添加这两个函数:

 function ShutdownEditEventForm(){
$(document).unbind(".EventPopupEvents");
HidePopup($("#EventPopup"));}

function HidePopup($popup){
$("#PopupBackground").hide();
$("#PopupBackground").remove();
$popup.hide();}

将其添加到您的表单加载以进行保存:

$("#EditEventSaveButton").click(function() { SaveEvent(id, onSaveCallback); });

hth :)

attach this to your form load event..

  $(document).bind("keyup.EventPopupEvents", null, function(event)
{
    if (event.keyCode == 27)
    {
        ShutdownEditEventForm();
    }
});

add these two functions:

 function ShutdownEditEventForm(){
$(document).unbind(".EventPopupEvents");
HidePopup($("#EventPopup"));}

function HidePopup($popup){
$("#PopupBackground").hide();
$("#PopupBackground").remove();
$popup.hide();}

add this to your form load for the save:

$("#EditEventSaveButton").click(function() { SaveEvent(id, onSaveCallback); });

hth :)

半葬歌 2024-09-07 09:40:43

通过对话框,我不确定您是指某些自定义 css 对话框还是 javascript 中的确认对话框。对于后者,这段代码应该可以正常工作。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
    </head>
    <body>
        <form method="get" action="focusout.htm">
            <input type="submit" id="button" value="Submit" />
        </form>
        <script type="text/javascript">

            $("#button").click(function () {
                return confirm("are you sure you want to click?");
            });
        </script>
    </body>
    </html>

By dialog im not sure if you are referring to some custom css dialog or a confirm dialog in javascript. For the latter this code should work just fine.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
    </head>
    <body>
        <form method="get" action="focusout.htm">
            <input type="submit" id="button" value="Submit" />
        </form>
        <script type="text/javascript">

            $("#button").click(function () {
                return confirm("are you sure you want to click?");
            });
        </script>
    </body>
    </html>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文