C# web Form web.aspx 跳出提示视窗的4种方法

一般在写ASP.NET是不太希望用
response.write来作页面输出。

因为用response.write输出的文字会一律在页面的最顶端
这样会破坏整个页面的排版。

一般会在想出现该文字的地方放一个Lable控制项,
然後指定Lable控制项的属性比如:颜色、字型大小、字体‥‥
e.g
string msg = Request.RawUrl;
Response.Write( "<script language='javascript'>alert('" + msg + "')");

string msg = Request.RawUrl;
Literal AlertMsg = new Literal();
AlertMsg.Text = "<script language='javascript'>alert('" + ProgID + "')";
this.Page.Controls.Add(AlertMsg);

方法二(注册 Client 的 Head Script):
string msg = Request.RawUrl;
//VS2013,会提醒己过时,但仍能用
Page.RegisterClientScriptBlock("AlertMsg", "<script language='javascript'>alert('" + msg + "')");

或是
string msg = Request.RawUrl;
ClientScript.RegisterClientScriptBlock(this.GetType(), "AlertMsg", "<script language='javascript'>alert('" + msg + "')");

4.//VS2013,会提醒己过时,但仍能用

string msg = "test test test";
Page.RegisterStartupScript("", "<script language=\'javascript\'>alert(\'" + msg + "\')</script>");

ref
http://www.blueshop.com.tw/board/FUM20041006161839LRJ/BRD200704282115222PL.html
https://awei791129.pixnet.net/blog/post/40389417
为什麽alert没有跳出来
https://roiafafa.pixnet.net/blog/post/184799187


这个拿到的会是网域後面的一大串.
string msg = Request.RawUrl;
e.g.
https://ithelp.ithome.com.tw/articles?tab=tech
msg = articles?tab=tech


<<:  CVSS v3.1如何计算其分数(强制性指标)

>>:  JS ES6 箭头函式常见问题 DAY74

Day14:全端工程师的工作内容?(上)

一、前言   因为我待的是较小型的接案公司,基本上全端工程师的工作几乎全包,从投标、接案、访谈客户需...

【在厨房想30天的演算法】Day 09 资料结构:伫列 Queue

Aloha!又是我少女人妻 Uerica!自从写了铁人赛文章後,因为我跟老公都太忙,我家狗狗对我发出...

30天学会C语言: Day 18-更多字串

格式化字串 格式化字串除了把变数转换成字串,还可以规定显示的位数 最小长度 在 % 的後面加上数字,...

Day 14 在VSCode中使用Azure

前言 由於接下来要开始写到attention和Capsule的实作,主要是会研究一些github或是...

Day 17 Dockerfile 和 Docker-Compose 的差异

「撰写完 dockerfile → 转成映像档 → 建立容器」的流程虽说不复杂,但随着要建立的容器一...