网页开发有时候也需要一些提示,可以作为调试时问题输出、也可以作为用户操作提醒。
下面来学习一下怎么在网页上添加提示框:
1、网页编辑文本中使用js脚本
可以在脚本里使用alert();方法来显示提示框
2、程序在C#文件里运行有时候也需要用到网页的提示框,那么可以在C#文件里编写拟化的JS脚本,然后通过网络编辑执行出来
例:
public static void MsgBox(string _Msg)
{
string StrScript;
StrScript = ("<script language=javascript>");
StrScript += ("alert('" + _Msg + "');");
StrScript += ("</script>");
System.Web.HttpContext.Current.Response.Write(StrScript);
}
效果图: