[英]Display a modal Pop up in ASP.NET MVC
I am currently developing an MVC project that requires giving the client 30 days trial. 我目前正在开发一个MVC项目,需要给客户30天的试用期。 As from 5 days to the end of the trial, i want to start displaying warning messages to the user.
从试用的5天到结束,我想开始向用户显示警告消息。 I registered a Subscription Attribute which works just like the Authorize Attribute in ASP.NET MVC.
我注册了一个Subscription属性 ,它的工作方式与ASP.NET MVC中的Authorize Attribute类似。
How it works: 这个怎么运作:
While the client is working i check if(trial period <= 5 days)
. 当客户正在工作时,我检查
if(trial period <= 5 days)
。
If true, an HttpSubscriptionExpiredResult
Action Result is returned, which produces a customized status code. 如果为true,则返回
HttpSubscriptionExpiredResult
Action Result,生成自定义状态代码。 This status code is intercepted by the SubscriptionModule
, which then redirects to the warning page. SubscriptionModule
拦截此状态代码,然后重定向到警告页面。
My Needs: 我的需求:
I want the warning Action Method to return a modal pop up (or just a pop up). 我想要警告Action Method返回一个模式弹出窗口(或只是一个弹出窗口)。 Or simply put: I want the warning message displayed in a modal pop up.
或者简单地说:我希望弹出一个模态弹出的警告信息。 This will prevent disrupting the client's work.
这样可以防止破坏客户的工作。 How do i achieve this?
我如何实现这一目标?
This status code is intercepted by the SubscriptionModule, which then redirects to the warning page .
SubscriptionModule拦截此状态代码, 然后重定向到警告页面 。
There are lots of methods to make an modal popup in HTML pages; 有很多方法可以在HTML页面中进行模态弹出; the simplest one is presented at Simple jQuery Modal Window Tutorial
最简单的一个在Simple jQuery Modal Window Tutorial中展示
In your warning page
put the following JavaScript code 在
warning page
输入以下JavaScript代码
$(document).ready(function () {
//id is the ID for the DIV you want to display it as modal window
launchWindow(id);
});
It shows a nice popup window. 它显示了一个不错的弹出窗口。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.