Can I have "common controls" for every page?

J

jmacduff

I have a set of pages ( about 10 ) that all have the same controls at
the top, however I am unable to put the controls the master page for
the site since the other 50 pages dont have the controls.

Is there a way that I can define a common template / etc where this
code can live 1 place and then I can just use it / insert it onto
these ten pages?

So for example if you wanted to put 4 text boxes on 10 pages with the
4 text boxes exactly the same... can I get away just cut/paste the 4
text boxes?

Basically a base class for the aspx page is what I am looking for..
sort of?

-Jeff
 
J

Juan T. Llibre

You can have more than 1 master page.

Just create a master page which has those controls,
and specify *that* master page in the 10 pages in question.
 
J

jmacduff

You can have more than 1 master page.

Just create a master page which has those controls,
and specify *that* master page in the 10 pages in question.

Hmm. .that might help... Quick question how would I get access to the
middle master page ( this new one ) custom controls from the code
behind of the individual asp pages? For example I cant just do
"this.textbox1" can I ?

Jeff
 
J

Juan T. Llibre

re:
!> Quick question how would I get access to the middle master page ( this new one )
!> custom controls from the code behind of the individual asp pages?
!> For example I cant just do "this.textbox1" can I ?

No, you can't.

Check out "To reference a control on the master page" sample code in this article:

http://msdn2.microsoft.com/en-us/library/xxwa0ff0.aspx





You can have more than 1 master page.

Just create a master page which has those controls,
and specify *that* master page in the 10 pages in question.

Hmm. .that might help... Quick question how would I get access to the
middle master page ( this new one ) custom controls from the code
behind of the individual asp pages? For example I cant just do
"this.textbox1" can I ?

Jeff
 
A

Alan Silver

Juan T. Llibre said:
You can have more than 1 master page.

Just create a master page which has those controls,
and specify *that* master page in the 10 pages in question.

Even better (if I may say so) might be to have the master page for these
10 pages be a child of the main master page. That way you get the
consistency of the main master page with the extra bits for these 10
pages, and you don't need to duplicate any code.

In other words, all pages on the site use Master1.master, but these 10
pages use Master2.master, which itself has Master1.master as its own
master.

Sorry Juan if this is what you meant, but it sounded like you were
suggesting having an entirely separate master page for these 10 pages,
rather than a nested master page. A separate one would lead to duplicate
code, with all the inherent problems that would cause.
 

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,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top