CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 12/11/2006 12:05:24 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 3 Views: 29 Favorited: 0 Favorite
4 Items, 1 Pages 1 |< << Go >> >|
Synthetik
Asp.Net User
Javascript Masterpage Error!12/11/2006 12:05:24 PM

0

Hi,
I'm having issues with some javascript code I use to display a popup Calendar.

My code works when I don't make use of master pages - as soon as I put my content in a master page - the javascript code does not work

My theory is: the master page adds a reference onto the page name (the CustomContent page) and my code cannot find the control on the page anymore?

 Any ideas?

MorningZ
Asp.Net User
Re: Javascript Masterpage Error!12/11/2006 3:44:04 PM

0

No, your theory is not correct... what happens is that the master page changes the ID's of your controls so they are guarenteed unique....

Check out the "FindControl, Javascript, and Naming Containers" section in this article:
http://www.odetocode.com/Articles/450.aspx


"If you make it idiot proof, they'll build a better idiot"
Synthetik
Asp.Net User
Re: Javascript Masterpage Error!12/12/2006 7:47:27 AM

0

Hi MorningZ, Thank you for your quick reply...

Regarding my theory: perhaps I should have worded it differently to avoid sounding like a dork...
The actual IDs of controls are different when the page is rendered (as you mentioned) to prevent name duplication

When the page is renderedm, the master page and any content pages inside are merged.  Instead of using the @Page directive,
the @Master directive is used to define the layout of the page being rendered and the master page contains the regular top-level html tags.(like head etc.) etc.

Anyway, thats my take on master pages. 

Thanks for the link - I'll check it out right away...

Synthetik
Asp.Net User
Re: Javascript Masterpage Error!12/12/2006 9:11:23 AM

0

I've managed to solve the problem, although this solution is an easy way out (lazy, actually)

As discussed in the above conversation, master pages rename controls to avoid naming confilcts.  This means that 'txtDateFrom', when rendered,
will not be called, and cannot be referred to as 'txtDateFrom'  Instead, view the HTML source when the page is rendered in your browser and search for your control. 

You will notice 'ctl00_ContentPlaceHolder1_txtDateFrom' (in my example)...

So, I simply referenced this name in my javascript code instead of my original txtDateFrom name and ASP.net was happy.

4 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Professional Asp.net 3.5 Sp1 Edition: In C# and Vb Authors: Bill Evjen, Scott Hanselman, Devin Rader, Pages: 1856, Published: 2009
ASP.Net 2.0 MVP hacks and tips Authors: David Yack, Joe Mayo, Scott Hanselman, Fredrik Normen, Dan Wahlin, J. Ambrose Little, Jonathan Goodyear, Pages: 400, Published: 2006
Professional Microsoft Office Sharepoint Designer 2007 Authors: Woodrow W. Windiscman, Bryan Phillips, Asif Rehmani, Pages: 552, Published: 2009
Beginning ASP.NET 3.5: In C# and VB Authors: Imar Spaanjaars, Pages: 734, Published: 2008
ASP.NET 2.0: a developer's notebook Authors: Wei Meng Lee, Pages: 326, Published: 2005

Web:
ASP.Net 2.0 - Master Pages: Tips, Tricks, and Traps master page masterpages asp.net 2.0. ... FindControl, JavaScript, and Naming Containers ... it will fail with a JavaScript error: 'Label1 is undefined'. ...
javascript error on masterpage - ASP.NET Forums I have created javascript code for that but gives me error says object required. I don't know what is wrong with it. Here is the code. ...
ASP.NET MasterPage + Javascript Error - Stack Overflow After converting an ASP.NET webform (v3.5) to use a master page, I started getting a strange Javascript error. The content page has a block of javascript. ...
ASP.NET 2.0 Master Page Problem Asp.net 2.0 Master Page Sub folder Relative URL error. Poster: phatmike11 ... However, I have not found a fix for the javascript! ...
ASP.NET Classic Controls - Rotator Forum - RadRotator Javascript ... NET: Rotator / RadRotator Javascript error with MasterPage ... But when I use it with a Visual Studio MasterPage, I get the following error: ...

MasterPage, Javascript, and XHTML : Microsoft JScript runtime ... MasterPage, Javascript, and XHTML : Microsoft JScript runtime error: Object expected, > ROOT > NEWSGROUP > Asp.Net Forum ...
Master Page Control Error - ng.asp-net-forum ... Master Page Control Error, > ROOT > NEWSGROUP > Asp.Net Forum ... MasterPage, Javascript, and XHTML : Microsoft JScript runtime . ...
Javascript in MasterPage - ng.asp-net-forum ... Javascript in MasterPage, > ROOT > NEWSGROUP > Asp.Net Forum ... ClientId' but in the case of MasterPage it gives an error that "Object refrence not set" ...
Master Page Class Type Error - ng.asp-net-forum ... Master Page Class Type Error, > ROOT > NEWSGROUP > Asp.Net Forum ... Javascript Object Expected Error, Master Pages & DetailsView Confl . ...
Javascript not executing when I include a Masterpage - ng.asp-net ... Javascript in MasterPages Still my program does not recognize my external ... radio button CheckedChanged is not executing. it gives the error on status bar ...












problem with logging in to the personal site starter kit.

pss beta 1 vs. beta 2 speed

blank menu entries when activating dynamic display

connecting to web service error - aspnetdb.mdf

remeber me next time

login problems

how to setup connection string

can starter kit be created without sql express 2005? (only using sql 2005)

extended pws starter kit 2.8 - revised sendmail routine causing exception

i can't create an administrative user!

help! how to make users active from the remote web site?

sqlexpress database file auto-creation error

dynamic themes

iis error “aspnetdb.mdf is read-only” but it is not set to read only?

photo album woes..

db to filesystem conversion

working locally on remote website

jeremy's personal website having problems in firefox?

hosting

gallary photos won't fully load when selected.

error running script

add user information to a nother table???

rtm version error?

microsoft personal web site starter kit

other templates?

asp.net configuration settings. help

paypal express button on page

code review - album access list

cannot login anymore? what happened...

another database question

 
Search This Site:

 
  Privacy | Contact Us
All Times Are GMT