PC Review


Reply
Thread Tools Rate Thread

display an alert only once

 
 
AAaron123
Guest
Posts: n/a
 
      5th Aug 2008
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


 
Reply With Quote
 
 
 
 
Munna
Guest
Posts: n/a
 
      6th Aug 2008
Hi

try this

on Page_Load

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

hope that helps

regards

Munna
 
Reply With Quote
 
AAaron123
Guest
Posts: n/a
 
      6th Aug 2008
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" <(E-Mail Removed)> wrote in message
news:ecdf6138-20f6-42ff-a46b-(E-Mail Removed)...
> Hi
>
> try this
>
> on Page_Load
>
> if(Page.IsPostBack==false)
> {
> //put script here to show only once
> }
>
> hope that helps
>
> regards
>
> Munna



 
Reply With Quote
 
AAaron123
Guest
Posts: n/a
 
      6th Aug 2008
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]" <(E-Mail Removed)> wrote in message
news:%23%(E-Mail Removed)...
> "AAaron123" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>> 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



 
Reply With Quote
 
AAaron123
Guest
Posts: n/a
 
      6th Aug 2008
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]" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> "AAaron123" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
> [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



 
Reply With Quote
 
AAaron123
Guest
Posts: n/a
 
      6th Aug 2008
I wonder what static/shared does in Asp.Net.
Something different then in windows?



"Mark Rae [MVP]" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> "AAaron123" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
> [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



 
Reply With Quote
 
Hans Kesting
Guest
Posts: n/a
 
      8th Aug 2008
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


 
Reply With Quote
 
AAaron123
Guest
Posts: n/a
 
      10th Aug 2008
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" <(E-Mail Removed)> wrote in message
news:umrgGnT%(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
Hans Kesting
Guest
Posts: n/a
 
      11th Aug 2008
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


 
Reply With Quote
 
AAaron123
Guest
Posts: n/a
 
      11th Aug 2008
lots of info there. thanks
"Hans Kesting" <(E-Mail Removed)> wrote in message
news:eCR3FM5%(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DISPLAY ALERT Faraz A. Qureshi Microsoft Outlook Discussion 1 23rd Jun 2009 02:25 PM
Display alert problem carl Microsoft Excel Programming 1 29th Nov 2007 08:28 PM
Display Alert =?Utf-8?B?RnJhbmtKSU4=?= Microsoft Excel Programming 4 10th Nov 2005 03:30 AM
Re: Alert Display Sue Mosher [MVP-Outlook] Microsoft Outlook VBA Programming 0 28th Jul 2004 02:58 PM
Display alert =?Utf-8?B?d3phcQ==?= Microsoft Excel Worksheet Functions 2 6th May 2004 07:41 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:05 PM.