Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 7th, 2005, 12:21 AM
jmcpeak's Avatar
Wrox Author
 
Join Date: Nov 2005
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.
 
Old November 7th, 2005, 01:35 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 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.
 
Old November 7th, 2005, 01:46 PM
jmcpeak's Avatar
Wrox Author
 
Join Date: Nov 2005
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.
 
Old November 7th, 2005, 02:27 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 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.





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.