如何添加对话框弹出框 [英] How to add dialog pop box
问题描述
亲爱的,
我想知道,每当api_login为空时,如何创建弹出对话框。我也想知道,我怎么能把url链接放在弹出框中。
使用系统;
使用 System.Collections.Generic;
使用 System.Data;
使用 System.Data.Entity;
使用 System.Data.Entity.Infrastructure;
使用 System.Linq;
使用 System.Net;
使用 System.Net.Http;
使用 System.Web;
使用 System.Web.Http;
命名空间 User_test_Jan14.Controllers
{
public class UserController:ApiController
{
private cdwEntities db = new cdwEntities();
// GET api / User
public IEnumerable< api_login> Getapi_login()
{
return db.api_login.AsEnumerable();
}
// GET api / User / 5
public api_login Getapi_login( string id)
{
api_login api_login = db.api_login.Find(ID);
if (api_login == null )
{
Response.Write( < script> alert('Your alert box')< / script>< /跨度>);
}
return api_login;
}
}
}
非常感谢您的回复和帮助。
您可以使用以下代码行编写一个简单的消息框:
Response.Write( < script> alert('你的警告框')< / script>);
你可以用这种方式将任何类型的HTML代码写回浏览器,在弹出窗口中放置一个链接(这是不可能的裸JavaScript消息框)您需要编写实际的HTML代码而不是Quote:< script> alert('Your alert box') < / script>
另一边注:
上面的代码可以仅用于* aspx.cs文件(default.aspx.cs,以防该站点被称为default.aspx)。否则你需要做类似的事情:
//default.aspx.cs:
< pre lang =cs> public partial class 默认值:System.Web.UI.Page
{
UserController controller = new Controller();
受保护 void Page_Load( object sender,EventArgs e)
{
if (controller.Getapi_login( YourId)== null )
{
Response.Write( < script> alert('你的警告框')< / script>);
}
}
}
Dear all,
I would like to know, how can I create a pop-up dialog box, whenever "api_login is null". I would also like to know, how can I put url link in the pop-up box as well.
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Http;
namespace User_test_Jan14.Controllers
{
public class UserController : ApiController
{
private cdwEntities db = new cdwEntities();
// GET api/User
public IEnumerable<api_login> Getapi_login()
{
return db.api_login.AsEnumerable();
}
// GET api/User/5
public api_login Getapi_login(string id)
{
api_login api_login = db.api_login.Find(id);
if (api_login == null)
{
Response.Write("<script>alert('Your alert box')</script>");
}
return api_login;
}
}
}
Many thanks for your response and help.
You can write a simple message box by using the following line of code:
Response.Write("<script>alert('Your alert box')</script>");
You can write any kind of HTML code back to the browser in this way, to put a link in the popup (which is not possible with the bare JavaScript Message Box) you would need to write actual HTML code instead ofQuote:"<script>alert('Your alert box')</script>"
Another side note:
The above code can only be used from an *aspx.cs file ("default.aspx.cs", in case the site is called "default.aspx"). Otherwise you would need to do something like:
//default.aspx.cs:
public partial class Default : System.Web.UI.Page { UserController controller = new Controller(); protected void Page_Load(object sender, EventArgs e) { if(controller.Getapi_login("YourId") == null) { Response.Write("<script>alert('Your alert box')</script>"); } } }
这篇关于如何添加对话框弹出框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!