473,473 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

RegisterStartupScript not executing script


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 ( [expression] )
this.Page.RegisterStartupScript("CallBothGrids", "<script
language=javascript> { showBothGrids(); }</script>");
else
this.Page.RegisterStartupScript("CallFundsOnly", "<script
language=javascript> { showFundsOnly(); }</script>");

The "CallFundsOnly is executed (the first time), but the "CallBothGrids" is
not. I don't see any error message when the page is rendered in Internet
Explorer.
Any idea of what could be wrong?

Thanks.
Mike
Nov 18 '05 #1
3 2421
There's nothing wrong with what you've shown us.

The possibilities are an error in your javascript or simply your if
expression is never evaluating to true.

Try replacing showBothGrids(); with alert('test'); and see if that works

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Mike" <Mi**@discussions.microsoft.com> wrote in message
news:1D**********************************@microsof t.com...

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 ( [expression] )
this.Page.RegisterStartupScript("CallBothGrids", "<script
language=javascript> { showBothGrids(); }</script>");
else
this.Page.RegisterStartupScript("CallFundsOnly", "<script
language=javascript> { showFundsOnly(); }</script>");

The "CallFundsOnly is executed (the first time), but the "CallBothGrids" is not. I don't see any error message when the page is rendered in Internet
Explorer.
Any idea of what could be wrong?

Thanks.
Mike

Nov 18 '05 #2
RegisterStartupScript renders the javascript just before the </form>, thus
your javascript is executing before the page has been fully rendered (or
even fully parsed). if your resize logic is using calculated values, they
may be zero at this time. move you resize logic to the body onload event,
which will fire after the page has rendered by the browser, and content has
been sized..
-- bruce (sqlwork.com)
"Mike" <Mi**@discussions.microsoft.com> wrote in message
news:1D**********************************@microsof t.com...

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 ( [expression] )
this.Page.RegisterStartupScript("CallBothGrids", "<script
language=javascript> { showBothGrids(); }</script>");
else
this.Page.RegisterStartupScript("CallFundsOnly", "<script
language=javascript> { showFundsOnly(); }</script>");

The "CallFundsOnly is executed (the first time), but the "CallBothGrids" is not. I don't see any error message when the page is rendered in Internet
Explorer.
Any idea of what could be wrong?

Thanks.
Mike

Nov 18 '05 #3

Karl,

I have already tried with "alert" but nothing is shown. I also used
breakpoints, and I am sure that the line of code is executed.

The postback is caused by a javascript refresh. I wonder whether this could
be the problem.

Mike
"Karl Seguin" wrote:
There's nothing wrong with what you've shown us.

The possibilities are an error in your javascript or simply your if
expression is never evaluating to true.

Try replacing showBothGrids(); with alert('test'); and see if that works

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Mike" <Mi**@discussions.microsoft.com> wrote in message
news:1D**********************************@microsof t.com...

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 ( [expression] )
this.Page.RegisterStartupScript("CallBothGrids", "<script
language=javascript> { showBothGrids(); }</script>");
else
this.Page.RegisterStartupScript("CallFundsOnly", "<script
language=javascript> { showFundsOnly(); }</script>");

The "CallFundsOnly is executed (the first time), but the "CallBothGrids"

is
not. I don't see any error message when the page is rendered in Internet
Explorer.
Any idea of what could be wrong?

Thanks.
Mike


Nov 18 '05 #4

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

Similar topics

3
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...
6
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? ...
2
by: Ollie | last post by:
I use javascript to open a child window from the browser (window.open.....) this is then registered with the system using Page.RegisterStartupScript, it display the child peffectly fine. The...
11
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...
5
by: Ahmed | last post by:
Hi all, Is there any way to replace a script I registered in Page Load with the method Page.RegisterStartupScript
7
by: sck10 | last post by:
Hello, I have the following sub in a class in my "App_Code" directory. The script is for setting focus on a particular control, but I get the error, "Name ClientScript Not declared". Also, I am...
9
by: C | last post by:
Hi, On a click event of a button I do some validation. If my validation is unsuccessful I display an alert to the user as below. string message = "This is a test alert.";...
3
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...
4
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...
0
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,...
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,...
0
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...
0
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...
0
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...
0
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 ...
0
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...

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.