473,405 Members | 2,349 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Emitting Client Script


Reposting here as you can practically see the tumbleweed blow by in
microsoft.public.dotnet.framework.aspnet.webcontro ls....

I've got a very simple custom control that requires a small section of
JavaScript to function at the client - nothing out of the ordinary.

In the overridden RenderContents method of my custom control I check
whether the required client script block has been registered with
Page.ClientScript.IsClientScriptBlockRegistered() and if not, register
it with Page.ClientScript.RegisterClientScriptBlock()

If I place the custom control on a web form, the script gets injected
into the page as expected and works as it should.

If, however, the control is placed onto a Master page the script doesn't
get injected and therefore the control fails to work; why is this
behaving differently when the control is placed on a Master page, and
what do I have to do to get it to work?
Feb 15 '08 #1
2 1241
RenderContents is the wrong time to register the script. as the script block
comes before the controls html, its too late to render it after you have
rendered the content. Suprised your code ever worked.

move the RegisterClientScriptBlock to OnPreRender where it belongs.
-- bruce (sqlwork.com)
"Ed Courtenay" wrote:
>
Reposting here as you can practically see the tumbleweed blow by in
microsoft.public.dotnet.framework.aspnet.webcontro ls....

I've got a very simple custom control that requires a small section of
JavaScript to function at the client - nothing out of the ordinary.

In the overridden RenderContents method of my custom control I check
whether the required client script block has been registered with
Page.ClientScript.IsClientScriptBlockRegistered() and if not, register
it with Page.ClientScript.RegisterClientScriptBlock()

If I place the custom control on a web form, the script gets injected
into the page as expected and works as it should.

If, however, the control is placed onto a Master page the script doesn't
get injected and therefore the control fails to work; why is this
behaving differently when the control is placed on a Master page, and
what do I have to do to get it to work?
Feb 15 '08 #2
bruce barker wrote:
RenderContents is the wrong time to register the script. as the script block
comes before the controls html, its too late to render it after you have
rendered the content. Suprised your code ever worked.

move the RegisterClientScriptBlock to OnPreRender where it belongs.
-- bruce (sqlwork.com)
How the hell did I miss that? *blush*

It's strange what you miss when it's staring you straight in the face!

>
"Ed Courtenay" wrote:
>Reposting here as you can practically see the tumbleweed blow by in
microsoft.public.dotnet.framework.aspnet.webcontr ols....

I've got a very simple custom control that requires a small section of
JavaScript to function at the client - nothing out of the ordinary.

In the overridden RenderContents method of my custom control I check
whether the required client script block has been registered with
Page.ClientScript.IsClientScriptBlockRegistered () and if not, register
it with Page.ClientScript.RegisterClientScriptBlock()

If I place the custom control on a web form, the script gets injected
into the page as expected and works as it should.

If, however, the control is placed onto a Master page the script doesn't
get injected and therefore the control fails to work; why is this
behaving differently when the control is placed on a Master page, and
what do I have to do to get it to work?
Feb 15 '08 #3

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

Similar topics

9
by: Kathryn | last post by:
Hiya I have a problem with using some client side and server side scripting together in an ASP. I'm using VBScript. What I'm trying to achieve is this - - Page loads up and some server side...
5
by: tmb | last post by:
Is there a way to use ASP to 'push' a new image to the client every 15 seconds or so? I guess the entire page will have to be 're-sent' to the client but I'm not sure. I'm trying to 'rotate'...
26
by: Don | last post by:
I'm writing an html page with some JavaScript that reads a web page into a client-side temp file, then reformats it, then submits that same file as a URL to the browser for display, via...
1
by: John Livermore | last post by:
I am unable to get ASP.NET to send down Javascript to my IE 6.0 browser for client side validation. To simplify the problem I have the following code snippet in from User Control that creates a...
4
by: Bob T | last post by:
Hi All, I am trying to pass a variable from my VB asp.net script (from for example Sub Page_Load in mypage.aspx.vb) to my Client side script. I have found and looked at a very good example...
9
by: Harry Smith | last post by:
While reading the documentation on IsStartupScriptRegistered, there is a reference to "client startup script" as "Determines if the client startup script is registered with the Page object." What...
7
by: lvpaul | last post by:
Hallo ! I am using IIS-Windows-Authentication in my intranet (web.config <authentication mode="Windows" /> <identity impersonate="true" /> How can I get the users (client) IP-Address ? I...
3
by: SimonZ | last post by:
In ASP.NET 1.0 all client ID's of controls run at server were the same as the rendered ones on the client. In ASP.NET 2.0 the client id of server control is different on server than on the...
2
by: allfyre | last post by:
Ok, to make a long story short, I'm Emitting some MSIL from a c# application. I know that THIS is the MSIL I want to be emitting: //**************************************************************...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
0
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...

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.