|
 |
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 .
|
 |
|
|

November 7th, 2005, 12:21 AM
|
 |
Wrox Author
|
|
Join Date: Nov 2005
Location: , Texas, USA.
Posts: 87
Thanks: 0
Thanked 18 Times in 17 Posts
|
|
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.
|

November 7th, 2005, 01:35 PM
|
 |
Wrox Author
Points: 71,804, Level: 100 |
|
|
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,050
Thanks: 80
Thanked 1,581 Times in 1,558 Posts
|
|
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.
|

November 7th, 2005, 01:46 PM
|
 |
Wrox Author
|
|
Join Date: Nov 2005
Location: , Texas, USA.
Posts: 87
Thanks: 0
Thanked 18 Times in 17 Posts
|
|
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.
|

November 7th, 2005, 02:27 PM
|
 |
Wrox Author
Points: 71,804, Level: 100 |
|
|
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,050
Thanks: 80
Thanked 1,581 Times in 1,558 Posts
|
|
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 |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |