473,804 Members | 2,985 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Having problems with 'RegisterStartU pScript'.

When I put this code in my load function it works just fine.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
RegisterStartup Script("", "<script language='JavaS cript'> CreateWnd
('PleaseWait.as px', 500, 50, false); </script>")
End Sub
But when I put it in another server control it doesn't work:

Private Sub ImageList_ItemC ommand(ByVal source As Object, ByVal e As
System.Web.UI.W ebControls.Data ListCommandEven tArgs) Handles
ImageList.ItemC ommand

RegisterStartup Script("", "<script language='JavaS cript'> CreateWnd
('PleaseWait.as px', 500, 50, false); </script>")

End Sub

Can someone tell me why this isn't working?
And here is the script code.
/*/
/ / Author: Jeremy Falcon
/ / Date: November 08, 2001
/ / Version: 1.4
/*/

/*/ THIS FILE CONTAINS FUNCTIONS THAT WILL WRAP THE POP-UP PROCESS /*/

// this variable will hold the window obect
// we only allow one pop-up at a time
var popup = null;

/*/
/ / PURPOSE:
/ / To create and center a pop-up window.
/ /
/ / COMMENTS:
/ / It will replace to old pop-up if called
/ / without calling DestroyWnd() first..
/*/

function CreateWnd (file, width, height, resize)
{
var doCenter = false;

if((popup == null) || popup.closed)
{
attribs = "";

/*/ there's no popup displayed /*/

// assemble some params
if(resize) size = "yes"; else size = "no";

/*/
/ / We want to center the pop-up; however, to do this we need to know
the
/ / screen size. The screen object is only available in JavaScript
1.2 and
/ / later (w/o Java and/or CGI helping), so we must check for the
existance
/ / of it in the window object to determine if we can get the screen
size.
/ /
/ / It is safe to assume the window object exists because it was
implemented
/ / in the very first version of JavaScript (that's 1.0).
/*/
for(var item in window)
{ if(item == "screen") { doCenter = true; break; } }

if(doCenter)
{ /*/ center the window /*/

// if the screen is smaller than the window, override the resize
setting
if(screen.width <= width || screen.height <= height) size = "yes";

WndTop = (screen.height - height) / 2;
WndLeft = (screen.width - width) / 2;

// collect the attributes
attribs = "width=" + width + ",height=" + height + ",resizable =" +
size + ",scrollbar s=" + size + "," +
"status=no,tool bar=no,director ies=no,menubar= no,location=no, top=" +
WndTop + ",left=" + WndLeft;
}
else
{
/*/
/ / There is still one last thing we can do for JavaScrpt 1.1
/ / users in Netscape. Using the AWT in Java we can pull the
/ / information we need, provided it is enabled.
/*/
if(navigator.ap pName=="Netscap e" && navigator.javaE nabled())
{ /*/ center the window /*/

var toolkit = java.awt.Toolki t.getDefaultToo lkit();
var screen_size = toolkit.getScre enSize();

// if the screen is smaller than the window, override the resize
setting
if(screen_size. width <= width || screen_size.hei ght <= height) size
= "yes";

WndTop = (screen_size.he ight - height) / 2;
WndLeft = (screen_size.wi dth - width) / 2;

// collect the attributes
attribs = "width=" + width + ",height=" + height + ",resizable =" +
size + ",scrollbar s=" + size + "," +
"status=no,tool bar=no,director ies=no,menubar= no,location=no, top=" +
WndTop + ",left=" + WndLeft;
}
else
{ /*/ use the default window position /*/

// override the resize setting
size = "yes";

// collect the attributes
attribs = "width=" + width + ",height=" + height + ",resizable =" +
size + ",scrollbar s=" + size + "," +
"status=no,tool bar=no,director ies=no,menubar= no,location=no" ;
}
}

// create the window
popup = open(file, "", attribs);
}
else
{
// destory the current window
DestroyWnd();
// recurse, just once, to display the new window
CreateWnd(file, width, height, resize);
}
}

/*/
/ / PURPOSE:
/ / To destroy the pop-up window.
/ /
/ / COMMENTS:
/ / This is available if wish to destroy
/ / the pop-up window manually.
/*/
Nov 19 '05 #1
4 1876
"=?Utf-8?B?Sm9zZXBoIEJ 1cnRvbg==?="
<Jo**********@d iscussions.micr osoft.com> wrote in
news:45******** *************** ***********@mic rosoft.com:
When I put this code in my load function it works just fine.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
RegisterStartup Script("", "<script language='JavaS cript'>
CreateWnd
('PleaseWait.as px', 500, 50, false); </script>")
End Sub
But when I put it in another server control it doesn't work:

Private Sub ImageList_ItemC ommand(ByVal source As Object, ByVal
e As System.Web.UI.W ebControls.Data ListCommandEven tArgs) Handles
ImageList.ItemC ommand

RegisterStartup Script("", "<script language='JavaS cript'>
CreateWnd
('PleaseWait.as px', 500, 50, false); </script>")

End Sub

Can someone tell me why this isn't working?


Joseph,

Why is the first parameter to RegisterStartup Script an empty string?

What do you mean by "this isn't working"? Do you get an error
message?

--
Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/
Nov 19 '05 #2
I put an empty string because I figured I didn't need to use a key value.

And I don't get an error message, its hits that part of the code and doesn't
do anything.

When I step through the code when its in the load function, I get my popup.
But when I do it anywhere else I don't get my popup.

"Chris R. Timmons" wrote:
"=?Utf-8?B?Sm9zZXBoIEJ 1cnRvbg==?="
<Jo**********@d iscussions.micr osoft.com> wrote in
news:45******** *************** ***********@mic rosoft.com:
When I put this code in my load function it works just fine.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
RegisterStartup Script("", "<script language='JavaS cript'>
CreateWnd
('PleaseWait.as px', 500, 50, false); </script>")
End Sub
But when I put it in another server control it doesn't work:

Private Sub ImageList_ItemC ommand(ByVal source As Object, ByVal
e As System.Web.UI.W ebControls.Data ListCommandEven tArgs) Handles
ImageList.ItemC ommand

RegisterStartup Script("", "<script language='JavaS cript'>
CreateWnd
('PleaseWait.as px', 500, 50, false); </script>")

End Sub

Can someone tell me why this isn't working?


Joseph,

Why is the first parameter to RegisterStartup Script an empty string?

What do you mean by "this isn't working"? Do you get an error
message?

--
Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/

Nov 19 '05 #3
Hi:

I believe you must complete the first parameter because it's an
identification.
--
Thales - Services Division
Bulnes 2756 P.5 - C1425DKX
Ciudad Autónoma de Buenos Aires
Tel.: (+5411) 4806-9146
Fax.: (+5411) 4807-0563
"Joseph Burton" wrote:
When I put this code in my load function it works just fine.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
RegisterStartup Script("", "<script language='JavaS cript'> CreateWnd
('PleaseWait.as px', 500, 50, false); </script>")
End Sub
But when I put it in another server control it doesn't work:

Private Sub ImageList_ItemC ommand(ByVal source As Object, ByVal e As
System.Web.UI.W ebControls.Data ListCommandEven tArgs) Handles
ImageList.ItemC ommand

RegisterStartup Script("", "<script language='JavaS cript'> CreateWnd
('PleaseWait.as px', 500, 50, false); </script>")

End Sub

Can someone tell me why this isn't working?
And here is the script code.
/*/
/ / Author: Jeremy Falcon
/ / Date: November 08, 2001
/ / Version: 1.4
/*/

/*/ THIS FILE CONTAINS FUNCTIONS THAT WILL WRAP THE POP-UP PROCESS /*/

// this variable will hold the window obect
// we only allow one pop-up at a time
var popup = null;

/*/
/ / PURPOSE:
/ / To create and center a pop-up window.
/ /
/ / COMMENTS:
/ / It will replace to old pop-up if called
/ / without calling DestroyWnd() first..
/*/

function CreateWnd (file, width, height, resize)
{
var doCenter = false;

if((popup == null) || popup.closed)
{
attribs = "";

/*/ there's no popup displayed /*/

// assemble some params
if(resize) size = "yes"; else size = "no";

/*/
/ / We want to center the pop-up; however, to do this we need to know
the
/ / screen size. The screen object is only available in JavaScript
1.2 and
/ / later (w/o Java and/or CGI helping), so we must check for the
existance
/ / of it in the window object to determine if we can get the screen
size.
/ /
/ / It is safe to assume the window object exists because it was
implemented
/ / in the very first version of JavaScript (that's 1.0).
/*/
for(var item in window)
{ if(item == "screen") { doCenter = true; break; } }

if(doCenter)
{ /*/ center the window /*/

// if the screen is smaller than the window, override the resize
setting
if(screen.width <= width || screen.height <= height) size = "yes";

WndTop = (screen.height - height) / 2;
WndLeft = (screen.width - width) / 2;

// collect the attributes
attribs = "width=" + width + ",height=" + height + ",resizable =" +
size + ",scrollbar s=" + size + "," +
"status=no,tool bar=no,director ies=no,menubar= no,location=no, top=" +
WndTop + ",left=" + WndLeft;
}
else
{
/*/
/ / There is still one last thing we can do for JavaScrpt 1.1
/ / users in Netscape. Using the AWT in Java we can pull the
/ / information we need, provided it is enabled.
/*/
if(navigator.ap pName=="Netscap e" && navigator.javaE nabled())
{ /*/ center the window /*/

var toolkit = java.awt.Toolki t.getDefaultToo lkit();
var screen_size = toolkit.getScre enSize();

// if the screen is smaller than the window, override the resize
setting
if(screen_size. width <= width || screen_size.hei ght <= height) size
= "yes";

WndTop = (screen_size.he ight - height) / 2;
WndLeft = (screen_size.wi dth - width) / 2;

// collect the attributes
attribs = "width=" + width + ",height=" + height + ",resizable =" +
size + ",scrollbar s=" + size + "," +
"status=no,tool bar=no,director ies=no,menubar= no,location=no, top=" +
WndTop + ",left=" + WndLeft;
}
else
{ /*/ use the default window position /*/

// override the resize setting
size = "yes";

// collect the attributes
attribs = "width=" + width + ",height=" + height + ",resizable =" +
size + ",scrollbar s=" + size + "," +
"status=no,tool bar=no,director ies=no,menubar= no,location=no" ;
}
}

// create the window
popup = open(file, "", attribs);
}
else
{
// destory the current window
DestroyWnd();
// recurse, just once, to display the new window
CreateWnd(file, width, height, resize);
}
}

/*/
/ / PURPOSE:
/ / To destroy the pop-up window.
/ /
/ / COMMENTS:
/ / This is available if wish to destroy
/ / the pop-up window manually.
/*/

Nov 19 '05 #4
>> > Private Sub ImageList_ItemC ommand(ByVal source As Object,
> ByVal e As
> System.Web.UI.W ebControls.Data ListCommandEven tArgs) Handles
> ImageList.ItemC ommand
>
> RegisterStartup Script("", "<script
> language='JavaS cript'> CreateWnd
> ('PleaseWait.as px', 500, 50, false); </script>")
>
> End Sub

Joseph,

When the user clicks on an item, are you expecting the above code to
cause the window to popup? If so, please realize that server-side
code cannot directly cause client-side JavaScript to execute. You
will have to inject calls to the JavaScript in the ASP.Net controls
when the page is built (this is usually done in Page_Load).

Unfortunately, there seems to be a lack of resources on the web as to
how to integrate client-side JavaScript code and server-side
ASP.Net code. It's quite elegant when you know how, but getting that
knowledge can be a real challenge.

Right now I'm pretty much guessing as to what you want your code to
do. So, if you'd like, please post a step-by-step description of
what you want to happen, something like:

- page with datagrid is displayed on the client
- user clicks an item in the datagrid
- client-side code shows a window in response to the click
- postback occurs

We can use an algorithm like this as a starting point to getting the
JavaScript calls wired into the correct places at the correct point
in the page's lifecycle.

--
Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/
Nov 19 '05 #5

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

Similar topics

3
8260
by: Lukman | last post by:
Hi, Could you tell me about what is RegisterStartupScript, I try to understand from MSDN sample, but I still don't understand. Could you give me more simple sample ? and what is the purpose of RegisterStartupScript. Thanks,
6
1988
by: Bill Jones | last post by:
I'm trying to use this.RegisterStartupScript to add some javascript to and aspx page that will run when the page is loaded. Does anyone know if this function only works in the Page_Load function? Or can I put it anywhere. Right now it is inside the eventhandler function that is called on the "CheckChanged" event of a checkbox, but it never seems to add the javascript code to the page. Is there another way to do this? Let me explain the...
11
3667
by: Stan Sainte-Rose | last post by:
Hi, I m working on a user control. I need to use a Js file, I would like to know how to load the js file using RegisterStartupScript command from the user control. Also, if I load the same user controls several times in the same webpage, do I have to check if the js file is still loaded ? Stan
3
2458
by: Mike | last post by:
Hi, I am trying to resize a HTML table through Javascript. When the user control loads the first time, the table is resized, but then it doesn't anymore. I am using the following code in the Load event of the web user control: if ( ) this.Page.RegisterStartupScript("CallBothGrids", "<script language=javascript> { showBothGrids(); }</script>"); else
2
1535
by: Marshal Antony | last post by:
Hi, I have a problem with using Page.RegisterStartupScript to call some javascript code from ASP.NET using C# is not working in Netscape.It is working fine in Internet Explorer.Does anybody know how to fix this problem? Any help is appreciated. Thanks, Marshal Antony ..NET Developer
0
1999
by: rom | last post by:
my main aspx page has 3 user controls. they are all located in the same place of the page and each time i set the visibility of 2 of them to false and 1 to true. now, i want to use the RegisterStartupScript on one of these controls but then i write page.RegisterStartupScript i registers it on the aspx page and i get js errors on the other controls. when i try me.RegisterStartupScript (on the ascx) i get "RegisterStartupScript is not e...
3
10433
by: MJP | last post by:
I have a button which kicks off the generation of a report after which the file will be downloaded. The report generation can take a long time, so client side onclick event of the button also makes a <span> tag visible which contains a nice message to the user thanking them for their patience. Of course after the report has been generated and downloaded this message should be removed. However, the RegisterStartupScript isn't working...
3
2041
by: Rob | last post by:
Hi, We've developed an ajax enabled web app which we're currently deploying to our production server. We use System.Web.UI.Page.RegisterStartupScript throughout the app, and all has worked well until we deployed. After deploying, we get an error stating that the method is not found. We're using .Net V2. After a bit of investigation, I get the impression that System.Web.UI.Page.RegisterStartupScript has been replaced by...
4
3902
by: =?Utf-8?B?RHVuZTg4?= | last post by:
I've got some code that uses Page.ClientScript.RegisterStartupScript to call a javascript function from the Page_Load method in the code behind. The code works fine in IE but the javascript function is not called at all in Firefox. I stripped my code back to the basics and all I have now is a webform with no controls on it and the following in the code behind: protected void Page_Load(object sender, EventArgs e) {...
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10325
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10315
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10075
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5519
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.