MasterPage Problems

I

Islamegy®

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??
 
B

Bruno Alexandre

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

Islamegy®

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 said:
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® said:
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??
 
B

Bruno Alexandre

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® said:
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 said:
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® said:
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??
 
I

Islamegy®

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 said:
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® said:
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 said:
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®" <[email protected]> escreveu na mensagem
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??
 
C

clintonG

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$__CustomNav2$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® said:
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 said:
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® said:
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??

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®" <[email protected]> escreveu na mensagem
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??
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top