473,836 Members | 1,480 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 1877
"=?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
8261
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
1989
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
2459
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
1537
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
2000
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
10435
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
2042
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
3903
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
9668
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10840
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10546
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...
0
9371
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5647
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
5823
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4448
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4013
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3112
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.