Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old November 7th, 2005, 12:21 AM
jmcpeak's Avatar
Wrox Author
Points: 467, Level: 7
Points: 467, Level: 7 Points: 467, Level: 7 Points: 467, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2005
Location: , Texas, USA.
Posts: 87
Thanks: 0
Thanked 18 Times in 17 Posts
Default MasterPage and ClientScript

I seem to be having problems with RegisterClientScriptBlock() when using MasterPages. No matter where I use RegisterClientScriptBlock(), the script is not added to the page. I've tried it in the Page_Load() and Page_Init() methods on both Master and Content pages. Just to check, I created a normal .aspx file and used RegisterClientScriptBlock() there and everything was hunky dory.

I can't seem to find any information on this issue, so any help would be appreciated.

Eat a beaver, save a tree.
  #2 (permalink)  
Old November 7th, 2005, 01:35 PM
Imar's Avatar
Wrox Author
Points: 71,804, Level: 100
Points: 71,804, Level: 100 Points: 71,804, Level: 100 Points: 71,804, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,050
Thanks: 80
Thanked 1,581 Times in 1,558 Posts
Default

Hi there,

Do you have other code in the content or master page that messes something up?? RegisterClientScriptBlock works fine for me in a content page.

BTW, Page.RegisterClientScriptBlock is now obsolete; you should use ClientScript.RegisterClientScriptBlock

And http://www.google.com/search?hl=en&q...master+page%22 brings up quite some useful results.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
  #3 (permalink)  
Old November 7th, 2005, 01:46 PM
jmcpeak's Avatar
Wrox Author
Points: 467, Level: 7
Points: 467, Level: 7 Points: 467, Level: 7 Points: 467, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2005
Location: , Texas, USA.
Posts: 87
Thanks: 0
Thanked 18 Times in 17 Posts
Default

Aye, I was using Page.ClientScript.RegisterClientScriptBlock().

As it turns out, I didn't have a form in my page, which seems to be causing the problem. I had performed quite a few Google searches, but nothing worthwhile came to my attention.

So as it stands now, I'm just a moron for not having the form in the page. Thanks for the reply!

Eat a beaver, save a tree.
  #4 (permalink)  
Old November 7th, 2005, 02:27 PM
Imar's Avatar
Wrox Author
Points: 71,804, Level: 100
Points: 71,804, Level: 100 Points: 71,804, Level: 100 Points: 71,804, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,050
Thanks: 80
Thanked 1,581 Times in 1,558 Posts
Default

Ha, I see. Can imagine that Google didn't tell you to add a form.... ;)

BTW, did you know you can add a ContentPlaceHolder to the <head>, so you can add custom JavaScript to a content page without the messy RegisterClientScript method?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Page.ClientScript.RegisterStartupScript & Threads VerbatimBOT ASP.NET 2.0 Professional 0 July 23rd, 2008 06:39 AM
ClientScript.GetCallbackEventReference() problem psychonet ASP.NET 2.0 Professional 0 September 5th, 2007 05:25 PM
ClientScript. : window.open -> Popup Blocker Issue AbrarNazeer ASP.NET 2.0 Professional 3 September 20th, 2006 10:59 AM



All times are GMT -4. The time now is 12:42 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.