473,775 Members | 2,625 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

RegisterStartup Script 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.Regis terStartupScrip t("CallBothGrid s", "<script
language=javasc ript> { showBothGrids() ; }</script>");
else
this.Page.Regis terStartupScrip t("CallFundsOnl y", "<script
language=javasc ript> { showFundsOnly() ; }</script>");

The "CallFundsO nly is executed (the first time), but the "CallBothGr ids" 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 2457
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**@discussio ns.microsoft.co m> wrote in message
news:1D******** *************** ***********@mic rosoft.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.Regis terStartupScrip t("CallBothGrid s", "<script
language=javasc ript> { showBothGrids() ; }</script>");
else
this.Page.Regis terStartupScrip t("CallFundsOnl y", "<script
language=javasc ript> { showFundsOnly() ; }</script>");

The "CallFundsO nly is executed (the first time), but the "CallBothGr ids" 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
RegisterStartup Script 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**@discussio ns.microsoft.co m> wrote in message
news:1D******** *************** ***********@mic rosoft.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.Regis terStartupScrip t("CallBothGrid s", "<script
language=javasc ript> { showBothGrids() ; }</script>");
else
this.Page.Regis terStartupScrip t("CallFundsOnl y", "<script
language=javasc ript> { showFundsOnly() ; }</script>");

The "CallFundsO nly is executed (the first time), but the "CallBothGr ids" 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**@discussio ns.microsoft.co m> wrote in message
news:1D******** *************** ***********@mic rosoft.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.Regis terStartupScrip t("CallBothGrid s", "<script
language=javasc ript> { showBothGrids() ; }</script>");
else
this.Page.Regis terStartupScrip t("CallFundsOnl y", "<script
language=javasc ript> { showFundsOnly() ; }</script>");

The "CallFundsO nly is executed (the first time), but the "CallBothGr ids"

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
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
1986
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...
2
2121
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 problem is that all the links on the parrent (main) window now display a blank page when clicked on, they work perfectly fine before the popup window is displayed. Anyone got any ideas why? Could it have anything to do with caching?
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
5
7613
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
4446
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 using MasterPages. How do I use "ClientScript.RegisterStartupScript" in a class? Public Shared Sub SetFocusControl(ByVal FocusControl As Control) Dim Script As New System.Text.StringBuilder Dim ClientID As String = FocusControl.ClientID
9
49458
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."; ClientScript.RegisterStartupScript(typeof(Page), "alert", "<script language=JavaScript>alert('" + (message) + "');</script>");
3
10426
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...
4
3901
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
9622
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
9454
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,...
1
10048
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
8939
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
6718
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
5486
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4017
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
3611
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2853
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.