在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
更多推荐
仅显示一次警报
发布评论