仅显示一次警报 [英] display an alert only once

查看:105
本文介绍了仅显示一次警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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.com写信息

新闻:ec ************************ ********** @ a70g2000 hsh.googlegroups.com ...
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******@gmail.comwrote in message
news:ec**********************************@a70g2000 hsh.googlegroups.com...




试试这个页面上的



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.com写在留言中

新闻:Oz ************** @ TK2MSFTNGP02.phx.gbl ...
"AAaron123" <aa*******@roadrunner.comwrote 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
http://www.markrae.net

Then use Session...

Session["blnFirstTime"] = true;

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


这篇关于仅显示一次警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆