仅显示一次警报

编程入门 行业动态 更新时间:2024-10-21 17:29:04
本文介绍了仅显示一次警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在Page_Load中我有以下想要弹出窗口第一次出现 (仅)显示页面。我每次都得到它。这可以解决吗? 谢谢 静态已经布尔=虚假 如果不是那么那么 beenHere = True Dim csname1 As String =" PopupScript" Dim cstype As Type = Me.GetType() Dim csm As ClientScriptManager = Page.ClientScript If(not csm.IsStartupScriptRegistered(cstype,csname1))然后 Dim cstext1 As New StringBuilder() cstext1.Append(" alert(''This is) cstext1.Append(" some text。'');") csm.RegisterStartupScript(cstype,csname1,cstext1.ToString,True ) 结束如果 结束如果

In Page_Load I have the following wanting the popup to appear the first time (only) that the page is displayed. I get it each time. Can this be fixed? thanks Static beenHere As Boolean = False If Not beenHere Then beenHere = True Dim csname1 As String = "PopupScript" Dim cstype As Type = Me.GetType() Dim csm As ClientScriptManager = Page.ClientScript If (Not csm.IsStartupScriptRegistered(cstype, csname1)) Then Dim cstext1 As New StringBuilder() cstext1.Append("alert(''This is ") cstext1.Append("some text.'');") csm.RegisterStartupScript(cstype, csname1, cstext1.ToString, True) End If End If

推荐答案

嗨 在Page_Load上试试这个 if(Page.IsPostBack == false) { //把脚本放在这里只显示一次 } 希望有帮助 问候 Munna Hi try this on Page_Load if(Page.IsPostBack==false) { //put script here to show only once } hope that helps regards Munna

试过但是它不起作用。 我猜是因为如果我移动到另一个页面然后返回,或者如果我刷新,那么 不是PostBack。 我想我注意了一个变量,其寿命一直持续到用户 离开网站。 感谢您的帮助。 " Munna" < mu ****** @ gmail写信息 新闻:ec ************************ ********** @ a70g2000 hsh.googlegroups ... Tried it but it doesn''t work. I''d guess because if I move to another page and return, or if I refresh, it is not a PostBack. I think I heed a variable that has a lifetime that lasts until the user leaves the site. Thanks for trying to help. "Munna" <mu******@gmailwrote in message news:ec**********************************@a70g2000 hsh.googlegroups... 嗨 试试这个页面上的 if(Page.IsPostBack == false) { //把脚本放在这里只显示一次 } 希望有帮助 问候 Munna Hi try this on Page_Load if(Page.IsPostBack==false) { //put script here to show only once } hope that helps regards Munna

" AAaron123" < aa ******* @ roadrunner写在留言中 新闻:Oz ************** @ TK2MSFTNGP02.phx.gbl ... "AAaron123" <aa*******@roadrunnerwrote in message news:Oz**************@TK2MSFTNGP02.phx.gbl... 我想我注意了一个变量,其寿命一直持续到用户 离开网站。 I think I heed a variable that has a lifetime that lasts until the user leaves the site.

然后使用Session ... Session [" blnFirstTime"] = true; if((bool)Session [" blnFirstTime"] == true) { //运行一次 Session [" blnFirstTime"] = false; } - Mark Rae ASP。 NET MVP www.markrae

Then use Session... Session["blnFirstTime"] = true; if ((bool)Session["blnFirstTime"] == true) { // run once Session["blnFirstTime"] = false; } -- Mark Rae ASP.NET MVP www.markrae

更多推荐

仅显示一次警报

本文发布于:2023-11-27 12:18:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638046.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:警报

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!