Does anybody know an official way to setup one control on many pages, for
example menu? Since we're not having a visual inheritance yet it's not very
easy. One of the possible ways as I see is to copy the html code of this
control manually to all aspx pages and then use some call probably to a base
class method on onload to initialize and fill this control. I see that crazy
because if we need to correct something then we need to correct all pages,
but that's brainless.
How can we insert the html code of this control to all our pages on runtime?
I know that we can insert a JAVA script using RegisterClientScriptBlock, but
what about pure HTML?
Thanks,
Just D. 4 1048
Convert the control to a UserControl and have all of your pages derive from
a custom class derived from System.Web.UI.Page (like MyAppPage : Page).
Then, in MyAppPage.Page_Load or MyAppPage.Page_Init add the control to the
page's Controls collection.
Depending on how you code the control (directly rendering HTML with the
Render() method or if the HTML is contained in an .ascx file) you can either
call it as Page.Controls.Add(new MyMenu()); or
Page.Controls.Add(Page.LoadControl("MyMenu.ascx")) ; http://msdn.microsoft.com/library/de...classtopic.asp
HTH
----------------
Dave Fancher http://davefancher.blogspot.com
For now, unless your web site is huge, it's easiest to just drag a control
onto each page.
Another approach would be to use an HTTPHandler to inject one into the
output stream.
Here's more info: http://SteveOrr.net/faq/UserCustom.aspx http://msdn.microsoft.com/library/de...ebControls.asp
--
I hope this helps,
Steve C. Orr, MCSD, MVP http://SteveOrr.net
"Just D." <no@spam.please> wrote in message
news:BRYde.989$eU.451@fed1read07... Does anybody know an official way to setup one control on many pages, for example menu? Since we're not having a visual inheritance yet it's not very easy. One of the possible ways as I see is to copy the html code of this control manually to all aspx pages and then use some call probably to a base class method on onload to initialize and fill this control. I see that crazy because if we need to correct something then we need to correct all pages, but that's brainless.
How can we insert the html code of this control to all our pages on runtime? I know that we can insert a JAVA script using RegisterClientScriptBlock, but what about pure HTML?
Thanks, Just D.
Thanks Steve,
I think that's what I wanted. I can't say that it's huge, only 130 pages
including some menu related and secondary pages... The application is
expecting to be really huge, that's true, and this approach will help to
solve this problem. Right now I'm having this control on about 60 pages, it
was easy to add it to macro and insert to all ASPX pages, but it's not
convenient for sure.
Thanks,
Just D.
"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl... For now, unless your web site is huge, it's easiest to just drag a control onto each page. Another approach would be to use an HTTPHandler to inject one into the output stream.
Here's more info: http://SteveOrr.net/faq/UserCustom.aspx http://msdn.microsoft.com/library/de...ebControls.asp
-- I hope this helps, Steve C. Orr, MCSD, MVP http://SteveOrr.net
"Just D." <no@spam.please> wrote in message news:BRYde.989$eU.451@fed1read07... Does anybody know an official way to setup one control on many pages, for example menu? Since we're not having a visual inheritance yet it's not very easy. One of the possible ways as I see is to copy the html code of this control manually to all aspx pages and then use some call probably to a base class method on onload to initialize and fill this control. I see that crazy because if we need to correct something then we need to correct all pages, but that's brainless.
How can we insert the html code of this control to all our pages on runtime? I know that we can insert a JAVA script using RegisterClientScriptBlock, but what about pure HTML?
Thanks, Just D.
You can create a Visual Studio template using the information in the
following link, although it's not nearly as easy as it should be.
Here are the details: http://www.sellsbrothers.com/writing...mtemplates.htm
In Visual Studio 2005 creating templates will be much easier. There will
also be Master Pages that will allow all your pages to inherit a common
structure. http://www.c-sharpcorner.com/Code/20...asterPages.asp
--
I hope this helps,
Steve C. Orr, MCSD, MVP http://SteveOrr.net
"Just D." <no@spam.please> wrote in message
news:TL%de.1009$eU.570@fed1read07... Thanks Steve,
I think that's what I wanted. I can't say that it's huge, only 130 pages including some menu related and secondary pages... The application is expecting to be really huge, that's true, and this approach will help to solve this problem. Right now I'm having this control on about 60 pages, it was easy to add it to macro and insert to all ASPX pages, but it's not convenient for sure.
Thanks, Just D.
"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl... For now, unless your web site is huge, it's easiest to just drag a control onto each page. Another approach would be to use an HTTPHandler to inject one into the output stream.
Here's more info: http://SteveOrr.net/faq/UserCustom.aspx http://msdn.microsoft.com/library/de...ebControls.asp
-- I hope this helps, Steve C. Orr, MCSD, MVP http://SteveOrr.net
"Just D." <no@spam.please> wrote in message news:BRYde.989$eU.451@fed1read07... Does anybody know an official way to setup one control on many pages, for example menu? Since we're not having a visual inheritance yet it's not very easy. One of the possible ways as I see is to copy the html code of this control manually to all aspx pages and then use some call probably to a base class method on onload to initialize and fill this control. I see that crazy because if we need to correct something then we need to correct all pages, but that's brainless.
How can we insert the html code of this control to all our pages on runtime? I know that we can insert a JAVA script using RegisterClientScriptBlock, but what about pure HTML?
Thanks, Just D.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Julie |
last post by:
I am trying to set some checks on my tab pages. I have many sets of tab
control pages with many controls on each page. I have got the code on the
button to check each control to make sure it has an...
|
by: Grant Merwitz |
last post by:
Hi
Is there a way to add a control to my page through the Global.asax
I would like to place this code in the Session_Start page so its only added
to the first page the user visits.
TIA
|
by: McGeeky |
last post by:
Is there a way to get a user control to remember its state across pages? I
have a standard page layout I use with a header and footer as user controls.
Each page uses the same layout by means of...
|
by: FAQ server |
last post by:
-----------------------------------------------------------------------
FAQ Topic - How do I get the value of a form control?
-----------------------------------------------------------------------...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |