473,387 Members | 1,440 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

display an alert only once

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
Aug 5 '08 #1
11 2774
Hi

try this

on Page_Load

if(Page.IsPostBack==false)
{
//put script here to show only once
}

hope that helps

regards

Munna
Aug 6 '08 #2
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...
Hi

try this

on Page_Load

if(Page.IsPostBack==false)
{
//put script here to show only once
}

hope that helps

regards

Munna

Aug 6 '08 #3
"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.
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

Aug 6 '08 #4
That did not fix it and I think it should have so I'm now wondering if I'm
missing something else. Like once it's registered it persisted for the
session.

Maybe I need to unregester it the second time or if there is no unregister
maybe I need to register a dummy?

Any ideas?

Thanks

I included the code below

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?

Session("blnFirstTime") = True

If CBool(Session("blnFirstTime")) Then

Session("blnFirstTime") = False

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


"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:%2******************@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.

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

Aug 6 '08 #5
"AAaron123" <aa*******@roadrunner.comwrote in message
news:uE**************@TK2MSFTNGP02.phx.gbl...

[top-posting corrected]
>>I think I heed a variable that has a lifetime that lasts until the user
leaves the site.

Then use Session...

In Page_Load I have the following
Session("blnFirstTime") = True
There's your problem - you're resetting the Session variable to True every
time the page loads.

This needs to be done in Session_Start.
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 6 '08 #6
Not knowing anything about Global.asax I stumbled aroung a little but it's
ok now. So you solved my problem an I learned a little more.

Thanks
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
"AAaron123" <aa*******@roadrunner.comwrote in message
news:uE**************@TK2MSFTNGP02.phx.gbl...

[top-posting corrected]
>>>I think I heed a variable that has a lifetime that lasts until the user
leaves the site.

Then use Session...

In Page_Load I have the following
Session("blnFirstTime") = True

There's your problem - you're resetting the Session variable to True every
time the page loads.

This needs to be done in Session_Start.
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 6 '08 #7
I wonder what static/shared does in Asp.Net.
Something different then in windows?

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
"AAaron123" <aa*******@roadrunner.comwrote in message
news:uE**************@TK2MSFTNGP02.phx.gbl...

[top-posting corrected]
>>>I think I heed a variable that has a lifetime that lasts until the user
leaves the site.

Then use Session...

In Page_Load I have the following
Session("blnFirstTime") = True

There's your problem - you're resetting the Session variable to True every
time the page loads.

This needs to be done in Session_Start.
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 6 '08 #8
AAaron123 formulated the question :
I wonder what static/shared does in Asp.Net.
Something different then in windows?

The same as in Windows, but here the (single) webapplication is shared
between all users!
So if you want to keep 1 value for the entire site - fine.
If you want to keep 1 value per user - use Session.

Hans Kesting
Aug 8 '08 #9
What about if I want to maintain a counter of how many tine I was vested.
Would you do that with a file?

Thanks for the info below

"Hans Kesting" <ne*********@spamgourmet.comwrote in message
news:um****************@TK2MSFTNGP03.phx.gbl...
AAaron123 formulated the question :
>I wonder what static/shared does in Asp.Net.
Something different then in windows?


The same as in Windows, but here the (single) webapplication is shared
between all users!
So if you want to keep 1 value for the entire site - fine.
If you want to keep 1 value per user - use Session.

Hans Kesting


Aug 10 '08 #10
AAaron123 explained :
What about if I want to maintain a counter of how many tine I was vested.
Would you do that with a file?
I would keep counters in a database. Usually a site runs as a user that
can't write files, unless you specifically enable it.
For a file you would have to read it, decode the counter value,
increase it and write it back. And you would have to do this within a
"lock" so that some other request wouldn't interfere.
For a database you would just issue a command "update counters set
mycounter = mycounter+1" and the database should do all the locking
needed.

Hans Kesting
Aug 11 '08 #11
lots of info there. thanks
"Hans Kesting" <ne*********@spamgourmet.comwrote in message
news:eC****************@TK2MSFTNGP04.phx.gbl...
AAaron123 explained :
>What about if I want to maintain a counter of how many tine I was vested.
Would you do that with a file?

I would keep counters in a database. Usually a site runs as a user that
can't write files, unless you specifically enable it.
For a file you would have to read it, decode the counter value, increase
it and write it back. And you would have to do this within a "lock" so
that some other request wouldn't interfere.
For a database you would just issue a command "update counters set
mycounter = mycounter+1" and the database should do all the locking
needed.

Hans Kesting


Aug 11 '08 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Alex Li | last post by:
Dear js/xmlhttp experts, I spent hours but could not solve this problem and hope someone could give me a clue: a onclick event will invoke a function to do a few things: 1. make a hidden DIV...
10
by: DettCom | last post by:
Hello, I would like to be able to display or hide fields based on whether a specific Yes/No radio button is selected. This is in conjunction with a posting a just made here in the same group...
7
by: Stefan Finzel | last post by:
Hi, is there a way to change the display property on Windows Mobile 2003 SE Mobile/Pocket Internet Explorer? See following example. Please note: visibilty property has the same problem. Is...
2
by: Jake Barnes | last post by:
Imagine I've this block of HTML: <p>Alex Schein Mailing List <input type="checkbox" name="newslettersToUse" value="133156"> (<a href="mcControlPanel.php"...
5
by: libsfan01 | last post by:
function switch_display(switchme) { var el = document.getElementById(switchme); el.style.display = (el.style.display == 'none')? '' : 'none'; } im using this function to switch the display on...
3
by: Wayne Deleersnyder | last post by:
Hi All, I'm trying to create a function that will cause a pop-up alert to appear if dates which were chosen from a drop-down list were invalid on a page. There's 4 dates, so there's the...
9
by: tshad | last post by:
This was posted before but the message got messed up (all NLs were stripped out for some reason). I have 2 labels that hold the name of different images on my .aspx page. <asp:Label ID="Logo"...
1
by: azgaranoop | last post by:
Hi, i want to display a alert box when a user leave my site.... Means if a user clck on X button i.e on top right corner of the browser or the user click on the address bar and try to change the...
3
by: pavanpvss | last post by:
hi , I have written a javascript function like this. function call(frm) { var loc_name = document.frm.loca.value; //alert('<'+loc_name+'>'); //var objRegExp =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.