Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 23rd, 2008, 11:46 PM
Authorized User
 
Join Date: Dec 2007
Posts: 38
Thanks: 2
Thanked 0 Times in 0 Posts
Default Page.RegisterStartupScript

Hi Imar,
I am developing a web project(vs 2005 & MsAccess) with vb.net .In my Home page I want to give some updates as alerts when a end user access or refresh the page.Here I am using RegisterStratupScript method to give alerts to page onload method.every thing is alright means I am getting only one alert ,it means the page is emiting only one alert. I want give 2 to 3 updates as alerts by calling RegisterStartupScript method.please help me how can I do it.I tried in many ways and searched google also. thanks in advance.

I am giving my code here.

Dim count as Integer=ds.Tables(0).Rows.count
Dim i as Integer
For i =0 to count
If i>=count then
     exit For
Else
     Dim dr As DataRow=ds.Tables(0).Rows(i)
     Dim strNews As String=dr("News")
     Dim strDate As dateAndTime=dr("startdate")
     Dim strMsg As String=strNews & "" & strDate

     Dim strScript As String="[script language=JavaScript]function Page_load(){alert('" & strMsg & "');}"
     strScript +="[/"
     strScript +="script]"

     Dim s As String=convert.ToString(i) 'key value
     Dim strAlert(count) As String 'string value
     strAlert(i)=strScript
     If not page.IsPostBack then
         If not ClientScript.IsStartupScriptRegistered(s) then
             ClientScript.RegisterStartupScript(s,strAlert( i))
             End If
    End If
End if
Next

In my table I have 3 updates,with above coding I am getting 3rd update only,Please help me how to get 3 updates as alerts.Sorry for my poor English,

Thanks in advance.

shanwaj
__________________
shanwaj
 
Old September 24th, 2008, 11:27 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 207
Thanks: 2
Thanked 15 Times in 15 Posts
Default

i think your issue is here

If not page.IsPostBack then

you are saying only run this code when the page initially loads but it sounds like to me you what this to run no matter what. get rid of that if statement.

Jason Hall
 
Old September 25th, 2008, 04:46 AM
Authorized User
 
Join Date: Dec 2007
Posts: 38
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Hi alliancejhall
  Thanks for your response.I done it without page postback.I am getting only one alert.I want to give 3 alerts to page load or page refresh.i dont want to call another aspx page as popup window.please suggest me how can i do it.

thanks in advance

shanwaj
 
Old September 28th, 2008, 09:41 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

One easy way around this is to simple extend the JavaScript code for multiple alerts:

alert('1');alert('2');alert('3');

would cause three alerts at the client. You can simply loop as you do now to build this string.

Personally, I don't like to get so many alerts. What's wrong with something like "3 records updated" as a single alert?

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
 
Old October 6th, 2008, 01:46 AM
Authorized User
 
Join Date: Dec 2007
Posts: 38
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Hi Imar,
  Sorry for my late reply, finally I given 3 updates as a single alert to page load.Yes I agree with u that no one can like so many alerts on page So I given 3 updates as single alert.thanks for your response.

shanwaj





Similar Threads
Thread Thread Starter Forum Replies Last Post
Page.ClientScript.RegisterStartupScript & Threads VerbatimBOT ASP.NET 2.0 Professional 0 July 23rd, 2008 05:39 AM
Problem calling RegisterStartupScript. KalpanaT ASP.NET 1.0 and 1.1 Basics 1 January 14th, 2008 03:52 AM
access C#.Net page as action of calssic ASP page mansharma_s ASP.NET 1.x and 2.0 Application Design 6 January 7th, 2008 10:58 AM
RegisterStartupScript - Postback from script gp_mk General .NET 4 April 14th, 2004 05:12 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.