473,387 Members | 1,321 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

2 Questions about using AJAX with Master Page

Hi,

Trying to create a master page that holds a menu, and the menu switches
between pages in the site. 2 problem arrosed:

a. When I navigate from page to page (all AJAX Web Forms, with the Master
pages as their master...) the entire page is refreshed - also the menu which
belongs to the master, how can I fix it - so only the inside content will be
refreshed ?

b. When I try to put an AJAX enabled control that I've created inside one of
the page, I get an error - either I don't have a Script manager (which is
located on the master page btw) or - if I add a script manager - that I have
1 too many...
so - I damned if I do and damned if I don't...

how can I create a control that only updates itself (it's a bunch of
comboboxes depends on each other) and put it in that kind of web page ?

Thanks,

Dani

Jun 27 '08 #1
10 2097
"Dani" <Da**@discussions.microsoft.comwrote in message
news:93**********************************@microsof t.com...
Trying to create a master page that holds a menu, and the menu switches
between pages in the site. 2 problem arrose:

a. When I navigate from page to page (all AJAX Web Forms, with the Master
pages as their master...) the entire page is refreshed - also the menu
which
belongs to the master, how can I fix it - so only the inside content will
be
refreshed ?
I'm afraid you've made the "classic" newbie misconception about MasterPages
that they are somehow the ASP.NET equivalent of framesets. They are nothing
at all like framesets. In fact, a MasterPage is nothing more than a special
kind of UserControl. When a content page is requested, it loads its
MasterPage control which it merges with its own markup and creates a single
page. This happens every time. That's how MasterPages work...
b. When I try to put an AJAX enabled control that I've created inside one
of
the page, I get an error - either I don't have a Script manager (which is
located on the master page btw) or - if I add a script manager - that I
have
1 too many...
so - I damned if I do and damned if I don't...
http://aspalliance.com/1285_Tip_and_...Master_Pages.5
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #2
Thanks for the quick reply.
Is there a "Good" way to write a site that uses a master page and doesn't
make the menu reload every time ?
Dani
"Mark Rae [MVP]" wrote:
"Dani" <Da**@discussions.microsoft.comwrote in message
news:93**********************************@microsof t.com...
Trying to create a master page that holds a menu, and the menu switches
between pages in the site. 2 problem arrose:

a. When I navigate from page to page (all AJAX Web Forms, with the Master
pages as their master...) the entire page is refreshed - also the menu
which
belongs to the master, how can I fix it - so only the inside content will
be
refreshed ?

I'm afraid you've made the "classic" newbie misconception about MasterPages
that they are somehow the ASP.NET equivalent of framesets. They are nothing
at all like framesets. In fact, a MasterPage is nothing more than a special
kind of UserControl. When a content page is requested, it loads its
MasterPage control which it merges with its own markup and creates a single
page. This happens every time. That's how MasterPages work...
b. When I try to put an AJAX enabled control that I've created inside one
of
the page, I get an error - either I don't have a Script manager (which is
located on the master page btw) or - if I add a script manager - that I
have
1 too many...
so - I damned if I do and damned if I don't...

http://aspalliance.com/1285_Tip_and_...Master_Pages.5
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #3
"Dani" <Da**@discussions.microsoft.comwrote in message
news:69**********************************@microsof t.com...

[top-posting corrected]
>>a. When I navigate from page to page (all AJAX Web Forms, with the
Master
pages as their master...) the entire page is refreshed - also the menu
which belongs to the master, how can I fix it - so only the inside
content will
be refreshed ?

I'm afraid you've made the "classic" newbie misconception about
MasterPages
that they are somehow the ASP.NET equivalent of framesets. They are
nothing
at all like framesets. In fact, a MasterPage is nothing more than a
special
kind of UserControl. When a content page is requested, it loads its
MasterPage control which it merges with its own markup and creates a
single
page. This happens every time. That's how MasterPages work...

Is there a "Good" way to write a site that uses a master page and doesn't
make the menu reload every time ?
I've obviously not explained clearly enough - when I said "That's how
MasterPages work", that's what I meant...

Specifically, a MasterPage is just a UserControl like any other UserControl.
When you add a UserControl to a page, it gets loaded every time the page
loads. That's how UserControls work. A MasterPage is a UserControl, so it
gets loaded every time the page loads. That's how MasterPages work, because
MasterPages are UserControls...

MasterPages are't frames. That's not how MasterPages work...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #4
I haven't tried myself but wonder if the update panel can be loaded in the
content page. I presume that would produce desired results. Furthermore,
when the Menu control is in the Master there will likely be some additional
coding required.

Technically speaking, it should also be noted Mark is incorrect because the
MasterPage is --not-- a User Control per se but a unique type which
functions similar to a User Control and then only when the page is compiled.

Most people do not want to explain in detail. Since the typed Master
functions similar to a User Control it has become common to describe it as
such to help people understand that Master Pages do not function like HTML
Framesets.

I would go to http://odetocode.com/ as K. Scott Allen has done a lot of work
describing MasterPages but that was before AJAX so I don't know if he's done
anything in the context of using AJAX. Going to the forums at
http://asp.net/ would be helpful too.

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:er**************@TK2MSFTNGP05.phx.gbl...
"Dani" <Da**@discussions.microsoft.comwrote in message
news:69**********************************@microsof t.com...

[top-posting corrected]
>>>a. When I navigate from page to page (all AJAX Web Forms, with the
Master
pages as their master...) the entire page is refreshed - also the menu
which belongs to the master, how can I fix it - so only the inside
content will
be refreshed ?

I'm afraid you've made the "classic" newbie misconception about
MasterPages
that they are somehow the ASP.NET equivalent of framesets. They are
nothing
at all like framesets. In fact, a MasterPage is nothing more than a
special
kind of UserControl. When a content page is requested, it loads its
MasterPage control which it merges with its own markup and creates a
single
page. This happens every time. That's how MasterPages work...

Is there a "Good" way to write a site that uses a master page and doesn't
make the menu reload every time ?

I've obviously not explained clearly enough - when I said "That's how
MasterPages work", that's what I meant...

Specifically, a MasterPage is just a UserControl like any other
UserControl. When you add a UserControl to a page, it gets loaded every
time the page loads. That's how UserControls work. A MasterPage is a
UserControl, so it gets loaded every time the page loads. That's how
MasterPages work, because MasterPages are UserControls...

MasterPages are't frames. That's not how MasterPages work...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Jun 27 '08 #5
"clintonG" <no****@nowhere.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Technically speaking, it should also be noted Mark is incorrect because
the MasterPage is --not-- a User Control per se but a unique type which
functions similar to a User Control and then only when the page is
compiled.
A MasterPage absolutely is a UserControl.
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #6
So you should have no problem at all providing a URL from MSDN2 that
definitively and without question documents the typed Master as a User
Control.

<%= Clinton Gallagher
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
"clintonG" <no****@nowhere.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>Technically speaking, it should also be noted Mark is incorrect because
the MasterPage is --not-- a User Control per se but a unique type which
functions similar to a User Control and then only when the page is
compiled.

A MasterPage absolutely is a UserControl.
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Jun 27 '08 #7
re:
!So you should have no problem at all providing a URL from MSDN2 that
!definitively and without question documents the typed Master as a User Control.

clintonG :

Here's 3 URLs which list MasterPage Properties, Members and Methods :

http://msdn.microsoft.com/en-us/libr...roperties.aspx
http://msdn.microsoft.com/en-us/libr...e_members.aspx
http://msdn.microsoft.com/en-us/libr...e_methods.aspx

Notice that every single Property, Member and Method used/owned by
a MasterPage inherits from either Control, UserControl or TemplateControl.

Since the UserControl, Page and MasterPage classes all are subclasses of System.Web.UI.

See :
http://quickstarts.asp.net/QuickStar...=System.Web.UI

When an HTTP request is made for a page at run time, the master page and content
pages are combined into a single class with the same name as the content pages.

The *resulting* compiled, merged class derives from the Page class.

The MasterPage class derives (inherits, actually) from Control,
and is last in a chain which includes Control, TemplateControl and UserControl:

Here's the inheritance hierarchy for the MasterPage class :

System..::.Object
System.Web.UI..::.Control
System.Web.UI..::.TemplateControl
System.Web.UI..::.UserControl
System.Web.UI..::.MasterPage

The master page is initialized as the top control in a page's control hierarchy by
clearing the page's Controls array and adding the master page to the Control collection.

MasterPage inherits from UserControl...so it's a form of UserControl.
If it looks like a duck and quacks like a duck and inherits from a duck...it's a duck.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"clintonG" <no****@nowhere.comwrote in message news:eE**************@TK2MSFTNGP04.phx.gbl...
So you should have no problem at all providing a URL from MSDN2 that definitively and without question documents the
typed Master as a User Control.

<%= Clinton Gallagher
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message news:%2****************@TK2MSFTNGP06.phx.gbl...
>"clintonG" <no****@nowhere.comwrote in message news:%2****************@TK2MSFTNGP04.phx.gbl...
>>Technically speaking, it should also be noted Mark is incorrect because the MasterPage is --not-- a User Control per
se but a unique type which functions similar to a User Control and then only when the page is compiled.

A MasterPage absolutely is a UserControl.
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #8
"clintonG" <no****@nowhere.comwrote in message
news:eE**************@TK2MSFTNGP04.phx.gbl...

[top-posting corrected]
>>Technically speaking, it should also be noted Mark is incorrect because
the MasterPage is --not-- a User Control per se but a unique type which
functions similar to a User Control and then only when the page is
compiled.

A MasterPage absolutely is a UserControl.

So you should have no problem at all providing a URL from MSDN that
definitively and without question documents the typed Master as a User
Control.
No problem whatsoever:
http://msdn.microsoft.com/en-us/libr...asterpage.aspx

Note specifically:

Public Class MasterPage Inherits UserControl

public class MasterPage : UserControl

public ref class MasterPage : public UserControl

public class MasterPage extends UserControl

The directives that are valid on a master page are the same as those that
are available on a UserControl object.

Inheritance Hierarchy
System..::.Object
System.Web.UI..::.Control
System.Web.UI..::.TemplateControl
System.Web.UI..::.UserControl
System.Web.UI..::.MasterPage
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #9
Dani you need to scroll down to 5/20 and get into the discussion: Do you
prefer Master Page or User Controls?

Mark --and others-- usually cite this document [1] but if you went to school
and learned to read like I did nowhere does the documentation definitively
state the Master --IS A-- User Control but MSDN documentation does --imply--
the Master is --LIKE A-- User Control because it supports the same
directives are inherited so to speak. Furthermore, it may be a stretch to
say the Master is --A TYPE OF-- User Control as usually stated but again,
the documentation does not say this. It is all implied leaving the matter up
for speculation.

Now speaking of "inheritance" get this...

The User Control can also be understood as a Mulatto Control: like being
born when one parent is a Negro and the other Caucasian then what race are
you?
I'll actually use this analogy but prefer a "safer" analogy which really
puts the matter of implication into perspective in the 5/20 discussion so
don't miss it, the fur may start to fly ;-)

<%= Clinton Gallagher

[1] http://msdn.microsoft.com/en-us/libr...asterpage.aspx
[2] http://en.wikipedia.org/wiki/Mulatto
"Dani" <Da**@discussions.microsoft.comwrote in message
news:69**********************************@microsof t.com...
Thanks for the quick reply.
Is there a "Good" way to write a site that uses a master page and doesn't
make the menu reload every time ?
Dani
"Mark Rae [MVP]" wrote:
>"Dani" <Da**@discussions.microsoft.comwrote in message
news:93**********************************@microso ft.com...
Trying to create a master page that holds a menu, and the menu switches
between pages in the site. 2 problem arrose:

a. When I navigate from page to page (all AJAX Web Forms, with the
Master
pages as their master...) the entire page is refreshed - also the menu
which
belongs to the master, how can I fix it - so only the inside content
will
be
refreshed ?

I'm afraid you've made the "classic" newbie misconception about
MasterPages
that they are somehow the ASP.NET equivalent of framesets. They are
nothing
at all like framesets. In fact, a MasterPage is nothing more than a
special
kind of UserControl. When a content page is requested, it loads its
MasterPage control which it merges with its own markup and creates a
single
page. This happens every time. That's how MasterPages work...
b. When I try to put an AJAX enabled control that I've created inside
one
of
the page, I get an error - either I don't have a Script manager (which
is
located on the master page btw) or - if I add a script manager - that I
have
1 too many...
so - I damned if I do and damned if I don't...

http://aspalliance.com/1285_Tip_and_...Master_Pages.5
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #10
You say that all so well but tell me then please; does MasterPage
inherit --from-- User Control as you said or --through-- User Control, and
if strictly from User Control as you imply why then is the MasterPage not
injected --into-- the control tree the way a User Control is but the
compiler "redims" the control tree so it can wrap the MasterPage around it?
Can you quack that?


"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
re:
!So you should have no problem at all providing a URL from MSDN2 that
!definitively and without question documents the typed Master as a User
Control.

clintonG :

Here's 3 URLs which list MasterPage Properties, Members and Methods :

http://msdn.microsoft.com/en-us/libr...roperties.aspx
http://msdn.microsoft.com/en-us/libr...e_members.aspx
http://msdn.microsoft.com/en-us/libr...e_methods.aspx

Notice that every single Property, Member and Method used/owned by
a MasterPage inherits from either Control, UserControl or TemplateControl.

Since the UserControl, Page and MasterPage classes all are subclasses of
System.Web.UI.

See :
http://quickstarts.asp.net/QuickStar...=System.Web.UI

When an HTTP request is made for a page at run time, the master page and
content
pages are combined into a single class with the same name as the content
pages.

The *resulting* compiled, merged class derives from the Page class.

The MasterPage class derives (inherits, actually) from Control,
and is last in a chain which includes Control, TemplateControl and
UserControl:

Here's the inheritance hierarchy for the MasterPage class :

System..::.Object
System.Web.UI..::.Control
System.Web.UI..::.TemplateControl
System.Web.UI..::.UserControl
System.Web.UI..::.MasterPage

The master page is initialized as the top control in a page's control
hierarchy by
clearing the page's Controls array and adding the master page to the
Control collection.

MasterPage inherits from UserControl...so it's a form of UserControl.
If it looks like a duck and quacks like a duck and inherits from a
duck...it's a duck.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"clintonG" <no****@nowhere.comwrote in message
news:eE**************@TK2MSFTNGP04.phx.gbl...
>So you should have no problem at all providing a URL from MSDN2 that
definitively and without question documents the typed Master as a User
Control.

<%= Clinton Gallagher
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>>"clintonG" <no****@nowhere.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl.. .

Technically speaking, it should also be noted Mark is incorrect because
the MasterPage is --not-- a User Control per se but a unique type which
functions similar to a User Control and then only when the page is
compiled.

A MasterPage absolutely is a UserControl.
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

42
by: (PeteCresswell) | last post by:
I skimmed the MS spiel at http://msdn.microsoft.com/sql/express, and noted the part about "all inside the Visual Studio 2005 environment". Do the older SQL server tools for security and stored...
5
by: ggk517 | last post by:
We are trying to develop an Engineering application using PHP, Javascript with Informix as the back-end. Is it possible to retrieve data using Javascript but by accessing the Database. Say...
9
by: RBM007 | last post by:
Hello, I have created some pages in the (old) Atlas pages and migrated to AJAX version. After the update I noticed that any page containing ASP.NET AJAX won't compile anymore. Even if the same...
5
by: Darth Continent | last post by:
Hello, I'm trying to replicate the functionality presented here specific to the ModalPopup control: http://ajax.asp.net/ajaxtoolkit/ModalPopup/ModalPopup.aspx I've created a C# Ajax-enabled...
4
by: shamirza | last post by:
4 9 6 18.ATLAS-AJAX Note: - As an IT professional it's useful to know what the difference is between Hype and usefulness. For instance if there is a new technology coming in many programmers...
2
by: nicknack | last post by:
Hello. A little tricky situation: I have a master page. Inside that master page I have A div (With overflow:scroll) that contain an ajax updatePanel. Inside that updatePanel I have a tree. The...
2
by: =?Utf-8?B?REo=?= | last post by:
I have a peculiar problem here that I did not have until I migrated from ASP.NET 2.0 to 3.5. I use a master page for my application. Because the master page uses update panels I have the...
3
by: Bobby Edward | last post by:
I had a simple admin form for "Categories"... Details View: To INSERT new Category Grid View: To View, Edit and Delete all Categories I decided to put the INSERT Details View inside of a...
2
by: Johnson | last post by:
While I have done a substantial amount of ASP.NET programming, I have only dabbled with AJAX (update panels and a 3rd party JSON setup - jayrock - that directly updates the DOM). In any case, I'm...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.