473,395 Members | 1,931 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,395 software developers and data experts.

MasterPage Problems

In my project i have two master page which i change dynamic in runtime.. The
first one with 1 ContentPanel "onepanel.master", the second with 2
contentPanel"twopanel.master"..

but when i switch between them it don't work, if the default masterpage is
"onepanel.master" and try to change it in runtime, ContentPanel2 which is
exist in the loaded masterpage throw exception..
the same happen if the default is "twopanel.master" and switch it throught
exception when parsing html..
Is there anyway to work around this without have 2 pages??

Second Question.. I can't find controls using FindControl When use
masterpage, i notice that my page only have one control which is the
masterpage,
if i search deeper in Controls[0].FindControl i find 2 literal and 2
HtmlHead(!!!) .
Any ideas??
Jun 12 '06 #1
5 1724
I think all masters have to had the same number of contentHolders...

try that (in the page you have just one, add the 2nd to the bottom of the
page for example)

do not forget that both masters have to have the same id's for contentHolder
this is only vecause you are using it dynamically, normal use don't need
this issue.

--

Bruno Alexandre
(a Portuguese in Københanv, Danmark)
"Islamegy®" <Is******@Private.4me> escreveu na mensagem
news:%2****************@TK2MSFTNGP03.phx.gbl...
In my project i have two master page which i change dynamic in runtime..
The first one with 1 ContentPanel "onepanel.master", the second with 2
contentPanel"twopanel.master"..

but when i switch between them it don't work, if the default masterpage is
"onepanel.master" and try to change it in runtime, ContentPanel2 which is
exist in the loaded masterpage throw exception..
the same happen if the default is "twopanel.master" and switch it throught
exception when parsing html..
Is there anyway to work around this without have 2 pages??

Second Question.. I can't find controls using FindControl When use
masterpage, i notice that my page only have one control which is the
masterpage,
if i search deeper in Controls[0].FindControl i find 2 literal and 2
HtmlHead(!!!) .
Any ideas??

Jun 12 '06 #2
Is this a solution for the first issue, I must hv the same number and IDs
for contentpanels in all master pages!!!

ok.. What about find controls in runtime when use masterpage??

"Bruno Alexandre" <br*********@gmail.com> wrote in message
news:ud**************@TK2MSFTNGP02.phx.gbl...
I think all masters have to had the same number of contentHolders...

try that (in the page you have just one, add the 2nd to the bottom of the
page for example)

do not forget that both masters have to have the same id's for
contentHolder
this is only vecause you are using it dynamically, normal use don't need
this issue.

--

Bruno Alexandre
(a Portuguese in Københanv, Danmark)
"Islamegy®" <Is******@Private.4me> escreveu na mensagem
news:%2****************@TK2MSFTNGP03.phx.gbl...
In my project i have two master page which i change dynamic in runtime..
The first one with 1 ContentPanel "onepanel.master", the second with 2
contentPanel"twopanel.master"..

but when i switch between them it don't work, if the default masterpage
is "onepanel.master" and try to change it in runtime, ContentPanel2 which
is exist in the loaded masterpage throw exception..
the same happen if the default is "twopanel.master" and switch it
throught exception when parsing html..
Is there anyway to work around this without have 2 pages??

Second Question.. I can't find controls using FindControl When use
masterpage, i notice that my page only have one control which is the
masterpage,
if i search deeper in Controls[0].FindControl i find 2 literal and 2
HtmlHead(!!!) .
Any ideas??


Jun 12 '06 #3
imagine that you have a Label called myLabel and you want to set a new text
cType( MasterPage.FindControl("myLabel"), Label).Text = "this is the new
text"
MasterPage.FindControl("myLabel") is your object from masterPage, then you
cast it to a label so you can acess all the properties of a Label Object,
than you specify the property you want to acess, in this case Text, and you
bind the value you want.

you can do the same in two lines of code like:

Dim myNewLabel as Label = cType( MasterPage.FindContrl("myLabel"), Label )
myNewLabel.Text = "this is the new text"
--

Bruno Alexandre
(a Portuguese in Københanv, Danmark)
"Islamegy®" <Is******@Private.4me> escreveu na mensagem
news:eU**************@TK2MSFTNGP04.phx.gbl...
Is this a solution for the first issue, I must hv the same number and IDs
for contentpanels in all master pages!!!

ok.. What about find controls in runtime when use masterpage??

"Bruno Alexandre" <br*********@gmail.com> wrote in message
news:ud**************@TK2MSFTNGP02.phx.gbl...
I think all masters have to had the same number of contentHolders...

try that (in the page you have just one, add the 2nd to the bottom of the
page for example)

do not forget that both masters have to have the same id's for
contentHolder
this is only vecause you are using it dynamically, normal use don't need
this issue.

--

Bruno Alexandre
(a Portuguese in Københanv, Danmark)
"Islamegy®" <Is******@Private.4me> escreveu na mensagem
news:%2****************@TK2MSFTNGP03.phx.gbl...
In my project i have two master page which i change dynamic in runtime..
The first one with 1 ContentPanel "onepanel.master", the second with 2
contentPanel"twopanel.master"..

but when i switch between them it don't work, if the default masterpage
is "onepanel.master" and try to change it in runtime, ContentPanel2
which is exist in the loaded masterpage throw exception..
the same happen if the default is "twopanel.master" and switch it
throught exception when parsing html..
Is there anyway to work around this without have 2 pages??

Second Question.. I can't find controls using FindControl When use
masterpage, i notice that my page only have one control which is the
masterpage,
if i search deeper in Controls[0].FindControl i find 2 literal and 2
HtmlHead(!!!) .
Any ideas??



Jun 12 '06 #4
But this label is added in the child page not in the masterpage... When i
search in the way u mention i don't find the label!!!
any ideas??

"Bruno Alexandre" <br*********@gmail.com> wrote in message
news:uk**************@TK2MSFTNGP03.phx.gbl...
imagine that you have a Label called myLabel and you want to set a new
text
cType( MasterPage.FindControl("myLabel"), Label).Text = "this is the new
text"
MasterPage.FindControl("myLabel") is your object from masterPage, then you
cast it to a label so you can acess all the properties of a Label Object,
than you specify the property you want to acess, in this case Text, and
you bind the value you want.

you can do the same in two lines of code like:

Dim myNewLabel as Label = cType( MasterPage.FindContrl("myLabel"), Label )
myNewLabel.Text = "this is the new text"
--

Bruno Alexandre
(a Portuguese in Københanv, Danmark)
"Islamegy®" <Is******@Private.4me> escreveu na mensagem
news:eU**************@TK2MSFTNGP04.phx.gbl...
Is this a solution for the first issue, I must hv the same number and IDs
for contentpanels in all master pages!!!

ok.. What about find controls in runtime when use masterpage??

"Bruno Alexandre" <br*********@gmail.com> wrote in message
news:ud**************@TK2MSFTNGP02.phx.gbl...
I think all masters have to had the same number of contentHolders...

try that (in the page you have just one, add the 2nd to the bottom of
the page for example)

do not forget that both masters have to have the same id's for
contentHolder
this is only vecause you are using it dynamically, normal use don't need
this issue.

--

Bruno Alexandre
(a Portuguese in Københanv, Danmark)
"Islamegy®" <Is******@Private.4me> escreveu na mensagem
news:%2****************@TK2MSFTNGP03.phx.gbl...
In my project i have two master page which i change dynamic in
runtime.. The first one with 1 ContentPanel "onepanel.master", the
second with 2 contentPanel"twopanel.master"..

but when i switch between them it don't work, if the default masterpage
is "onepanel.master" and try to change it in runtime, ContentPanel2
which is exist in the loaded masterpage throw exception..
the same happen if the default is "twopanel.master" and switch it
throught exception when parsing html..
Is there anyway to work around this without have 2 pages??

Second Question.. I can't find controls using FindControl When use
masterpage, i notice that my page only have one control which is the
masterpage,
if i search deeper in Controls[0].FindControl i find 2 literal and 2
HtmlHead(!!!) .
Any ideas??



Jun 12 '06 #5
No, you don't need the same number of Content Templates in your MasterPages.
That advice is just plain wrong. When compiled the contents of the Content
Template are extracted and integrated into the control tree as required. The
Content Template itself is discarded. You can verify this by enabling trace
in a content page and reading the control tree. Where is the Content
Template? Poof! Gone as it is only used in the designer to isolate
declarations for the compiler.

When you use trace in this way you will also see the entire template
hierarchy where your control is located. You will also likely observe how
some template sections have been renamed. One way or the other we must use
the entire template hierarchy to reference a control nested in templates. An
example follows...

// Step 1 use code to determine which MasterPage is loaded
// Step 2 use trace to read the control tree to located the control you want
to reference
// Step 3 use the FindControl method to reference the control using the
control tree hierarchy grammar
// Note: changing the source can affect the control tree hierarchy which may
require you to change your FindControl control tree grammar.

// example control tree hierarchy
ctl00$InnerPanelContent$CreateUserWizard$__CustomN av2$CreateUserButton

// replicate control tree hierarchy grammar to cast the referenced control
to its type
Button createUserButton =
(Button)Page.Master.FindControl("InnerPanelContent ").FindControl("CreateUserWizard").FindControl("__ CustomNav2").FindControl("CreateUserButton");

// use the referenced control
createUserButton.Text == "Button Text";
<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/
"Islamegy®" <Is******@Private.4me> wrote in message
news:Oy*************@TK2MSFTNGP05.phx.gbl...
But this label is added in the child page not in the masterpage... When i
search in the way u mention i don't find the label!!!
any ideas??

"Bruno Alexandre" <br*********@gmail.com> wrote in message
news:uk**************@TK2MSFTNGP03.phx.gbl...
imagine that you have a Label called myLabel and you want to set a new
text
cType( MasterPage.FindControl("myLabel"), Label).Text = "this is the new
text"
MasterPage.FindControl("myLabel") is your object from masterPage, then
you cast it to a label so you can acess all the properties of a Label
Object, than you specify the property you want to acess, in this case
Text, and you bind the value you want.

you can do the same in two lines of code like:

Dim myNewLabel as Label = cType( MasterPage.FindContrl("myLabel"),
Label )
myNewLabel.Text = "this is the new text"
--

Bruno Alexandre
(a Portuguese in Københanv, Danmark)
"Islamegy®" <Is******@Private.4me> escreveu na mensagem
news:eU**************@TK2MSFTNGP04.phx.gbl...
Is this a solution for the first issue, I must hv the same number and
IDs for contentpanels in all master pages!!!

ok.. What about find controls in runtime when use masterpage??

"Bruno Alexandre" <br*********@gmail.com> wrote in message
news:ud**************@TK2MSFTNGP02.phx.gbl...
I think all masters have to had the same number of contentHolders...

try that (in the page you have just one, add the 2nd to the bottom of
the page for example)

do not forget that both masters have to have the same id's for
contentHolder
this is only vecause you are using it dynamically, normal use don't
need this issue.

--

Bruno Alexandre
(a Portuguese in Københanv, Danmark)
"Islamegy®" <Is******@Private.4me> escreveu na mensagem
news:%2****************@TK2MSFTNGP03.phx.gbl...
> In my project i have two master page which i change dynamic in
> runtime.. The first one with 1 ContentPanel "onepanel.master", the
> second with 2 contentPanel"twopanel.master"..
>
> but when i switch between them it don't work, if the default
> masterpage is "onepanel.master" and try to change it in runtime,
> ContentPanel2 which is exist in the loaded masterpage throw
> exception..
> the same happen if the default is "twopanel.master" and switch it
> throught exception when parsing html..
> Is there anyway to work around this without have 2 pages??
>
> Second Question.. I can't find controls using FindControl When use
> masterpage, i notice that my page only have one control which is the
> masterpage,
> if i search deeper in Controls[0].FindControl i find 2 literal and 2
> HtmlHead(!!!) .
> Any ideas??
>



Jun 12 '06 #6

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

Similar topics

9
by: Leffe Andersson | last post by:
Hi folks! I have a MasterPage with some public methods, and I would like to call them from a (app_code) class. Is it possible to set a directive or an assembly reference to a MasterPage from a...
9
by: User | last post by:
OK, I asked in a reply, but I've wasted far too long so I'm going to put a new post out there in hopes that it will be more visible. I have a MasterPage. I want to call a method declared in that...
3
by: Alex Maghen | last post by:
Hi. I'm a little confused about the code that resides in the code-behind of a MasterPage and the code that resides in the code-behind of the actual pages that USE that MasterPage. I'm noticing,...
2
by: Alex Maghen | last post by:
I want to create a utility function that will seach the current page for one of my UserControls by it's type. So, let's say that I have a UserControl whose class I defined as follows: namespace...
4
by: cevans | last post by:
Is there a way to load a MasterPage programmatically? Not switch a page's masterpage but to create a MasterPage object that holds a given masterpage. So I know I can do: MasterPage master =...
7
by: Bon | last post by:
Dear all I create a master page with image buttons on the left-hand side for navigation. When a user clicks the student button, the content (i.e. ContentPlaceholder) in masterpage will be...
0
by: Steve | last post by:
I'm developing an ASP.Net 2 web site using VS 2005 that is using a MasterPage with a Table on it. The table has three columns - each with contentPlaceHolder. After developing the MasterPage, I...
2
by: Frank Milverckowitz | last post by:
Hi, New to .NET... question about Masterpages vs. using Frameset I'm using Visual Studio 2005 and notice that the generated pages are of DTD/Doctype that don't support framesets. To use...
0
by: saukpatthanshwe | last post by:
In myproject, there are three Master Pages under Master Folder. And I have many subfolders storing aspx pages which use that MasterPages. The Problem is that aspx pages in the root directory , the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...

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.