简体   繁体   English

如何在ASP.NET MVC中使用弹出框(警报)

[英]how use a popup box (alert) in ASP.NET MVC

i'am new in ASP.net MVC 我是ASP.net MVC新手

I want to upper a popup box when i click on an Html button , and when i confirm this Alert i want to be redirected to a specificed Action in my controller. 当我单击一个Html按钮时,我想在弹出框的上方,并且当我确认此Alert我想重定向到控制器中的特定Action

Any ideas please. 有什么想法。

use jQuery , you'll need to understand Dialog and javascript callback methods. 使用jQuery ,您需要了解Dialog和javascript callback方法。

Example of a user giving a text response: http://www.jquery4u.com/snippets/jquery-alert-box/ 用户给出文本回复的示例: http : //www.jquery4u.com/snippets/jquery-alert-box/

Example of a dialog box with Yes and No buttons: Yes or No confirm box using jQuery 具有“是”和“否”按钮的对话框的示例: 使用jQuery的“是”或“否”确认框

To invoke an action on a controller you could do this, javascript: 要在控制器上调用动作,您可以执行以下操作:javascript:

window.location.href = "/ControllerName/DoIt?id=12345&msg=hello";

or 要么

$.ajax( {url:"/ControllerName/DoIt",
        data: "id=12345&msg=hello",
        success: function (data){
        }
});

Your controller method would look like this: 您的控制器方法如下所示:

public ActionResult DoIt(int id, string msg )
{
   .....
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM