Re: Trouble with Javascript when converting 2003 webproject to a 2005 project using Master Pages

Tech-Archive recommends: Fix windows errors by optimizing your registry



> Another strange thing: suddenly there's a new <form> in the page which I
> haven't created: aspnetForm. I think this is created by the master page but
> I'm not sure.

Yes, this will be the server-side form created by default in the master
page; all the content placeholders should fall within it so you can use
server controls within your Content blocks without putting a <form
runat="server"> on each individual page.

> The original page has some Javascript in it which ofcourse references to
> controls in a form in the page. The form name is "frmContent", the control
> is "txtSubject".

If the form is server-side (runat="server"), then it could create
problems, as you may usually only have one server-side form per page
(which the master has provided for you)...

> However when this page is in the content of
> a master page the frmContent form had vanished from the rendered page (view
> source).

....so, you shouldn't need to have separate <form> elements in the
content-placeholder, and removing those tags may cause the contents to
render properly.

> the txtSubject control is renamed to:
> ctl00_phMasterContent_txtSubject. Obviously the existing Javascript will not
> function anymore.

This "name mangling" is necessary to keep identifiers unique within
different parts of the page. You can work around it by substituting the
result of <% txtSubject.ClientID %> into the Javascript at the relevant
points in place of txtSubject, and the correct form name instead of
frmContent; however, this might be tedious if you have large amounts of
code that needs modifying in this way. You could possibly set up a
Javascript object called frmContent [and call the real form something
different] then add members to it with names corresponding to the
original names, pointing to the actual controls with mangled names
inserted as above.

.



Relevant Pages

  • Re: asp.net 2.0 master pages problem
    ... >Scott, your closing statement is not neccessarily correct when controls are ... >> Page_Load for both the content page and the master). ... I think the Calendar is a bit quirky in this respect. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: ASP.net 2 Master pages menu and saving pages - Weired situation - please help
    ... The only downside here is if you use autopostback instead of AJAX on certain controls. ... But, if you want to just automatically save the stuff, then your nav links in your master page will have to be linkbuttons which will post and execute whatever code is necessary in each of your pages in the Page_Load in an ifblock. ... The problem that I have is that once the users are selecting ... IManageable that the base class implements it. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: asp.net 2.0 master pages problem
    ... your closing statement is not neccessarily correct when controls are ... > The SelectedDate property of the Calendar will not be updated until ... > Page_Load for both the content page and the master). ... I think the Calendar is a bit quirky in this respect. ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: Still no sound. I have a Dell Demension 2350 and a Intel 82801Soundcard.
    ... All the sliders are off zero and unmuted, not just master volume, none are that high, but my speakers are turned up so load, the kids in the dorm building over are going to be angry when I finally here this test sound. ... Did you turn all of the volume controls up or just the master volume? ... alias usb-controller ehci-hcd ...
    (Fedora)