I've been working on a project and I noticed I reuse the same menu over and over again and it got to a point where, if I needed to change something I would need to change 20+ pages too because of it being a menu.
My question is, is it possible to have a single aspx file with the working menu on it, and have the other pages call it? So far I've tried
<?php include('Menu.aspx') ?>
<iframe id="myIframe" src="Menu.aspx" height="100%" width="100%"></iframe>
The later (iframe) showed something but I was unable to resize it and the links didn't work either. The php one didn't show anything. Any help would be appreciated, thank you very much.
You can use the following approaches to solve this:
Master Pages allow to have a common layout that is applied to several aspx pages. The master page defines a layout and provides some content placeholders that are filled in by the pages that reference the master page. Your example of a menu fits good; the menu would be placed on the master page. See this link for details.
Another way to share layouts are ASP.NET UserControls. These are created as ascx files and can be reused in several aspx pages. See this link for details.
The best option for you is to create an User Control, and use it in all your pages.
An user control is similar to a server control (e.g. asp textbox, update panel etc.), but custom made by the developer to suit his specific needs.
If the menu is more like the common layout/theme of all your pages you can use a Master Page instead.
You have to make yourself familiar with master pages. See this as a beginner tutorial: http://www.codeproject.com/Articles/333650/Beginner-s-Tutorial-on-Master-Pages-in-ASP-NET
There are two option to reuse menu in asp.net page.
Master Page
User Control
using sitemap and add into master page.
https://msdn.microsoft.com/en-us/library/aa581781.aspx
http://webproject.scottgu.com/CSharp/MasterPages/MasterPages.aspx
Hope this will help you.
thanks
Related
I am creating a web application C# asp.net . I have a simple menu but I do no know if using
iframes to show different options according to the menu is better than using a masterpage.
I am pretty new at this. I read that iframes are not being used anymore.
Is there any other option that I can use?
Thanks
Yeah, I wouldn't use iframes in that context. At one point they were used to give the impression of something akin to Ajax, but you'll really only find them used these days for embedding videos, audio, etc. from other sites (e.g. YouTube, Soundcloud). Master pages should suffice - you'll have a master page with the menu itself, and any menu selection will load an entirely different page, albeit with the same menu provided by the master page. If you're looking to provide navigation without an entire page refresh, then you're getting into the realm of SPAs (single page applications), which will require the use of Ajax.
We would like to create a new website with a common menu and navbar across all the pages (except start/login page) .
The thing is that we are going to use the twitter bootstrap framework and dont know if this could be achieved with the framework only (or with any html + css trick)...
Previously we have used iframes for this cases but we prefer to do a frameless website this time and dont know how the framework will behave with master pages...
Any suggestions? If the only way is using master pages, could you provide some sample or link?
Use asp.net master pages. I think this has nothing to do with twitter bootstrap framework.
Create a empty parent masterpage with a header and a body container only.
Create two web forms using the parent master page for the start and login pages.
Create a children master page using the parent master page and implement the menu on the children.
Create everything else using the children master page so you will have a menu on every page.
If you want a menu less page, use the parent.masterpage. If you want the menu version, use the children.masterpage.
Master page is the way to go. Here is a walk through.
You should use a master page. Here is a link to the asp.net tutorial on master pages: http://www.asp.net/web-forms/tutorials/master-pages
I have some pages in the win8 application, most of which have a similar layout, I use Frame.Navigate to switch the pages. Just wonder if there is something like MasterPage in asp.net webform/mvc.
Just create a page with the layout you want and then use templates to customize it for particular views. You could have one main view .xaml file and then create a resource dictionary file (for separation purposes) for each different way you use it.
Edit:
I found someone who made a "Master Page" for wpf. See here. You could do something similar for metro.
I have an ASP.NET web application that I am making and I am thinking of making it a tabbed interface using Telerik's RadTabStrip. I am trying to figure out the best way to approach this though. I would need about 10 tabs because I have about 10 different main areas of my application. My question is how is the best way to integrate the content into the tabs. All of the simple examples I've seen create RadViews with imbedded HTML/ASP.NET content. The problem with this approach is that, with 10 tabs, it would make my main ASPX file really really big and it would be kind of clumsy to work with, having to integrate all 10 pages into one page. Is there a better or more accepted way to accomplish this?
I think, you have several possibilities:
Use one RadTabStrip and several RadView controls. Put the content for each tab into a separate user control (*.ascx). Then you only have to include the user controls in your main aspx page.
Use a master page and put the RadTabStrip on it. Create a separate page for each area of your application (each using the same master page). Use the RadTab's NavigateUrl property to navigate to the corresponding page (as shown in this demo).
there are certainly other possibilities...
Hii..
I am using a Multiview for a application. Each aspx page contains Multiview.
A single multiview contains atleast 5 to 6 views. (so less no. of aspx pages). When user clicks any button such as say "Edit View" (where user can edit his entries), a diffrent view is displayed. So user feels that he is redirected to another page. So a single aspx page has lot of controls, lot of code - a lil bit heavy page.
Will it affect loading time? is it better to use different aspx pages?
It is better to use different pages for different views. The number of aspx pages doesn't affect the performance, but managing each view on its own page is easier for maintenance.
You may use Multiview for some sort of wizard, but it is better to not use it to just reduce the number of aspx pages in the app.
Alex is right. Even if your views aren't displayed the controls contained in those views are persisted in the __VIEWSTATE. if you take a look at the source of your pages in your browser theres proably going to be a few Kb's of VIEWSTATE.
A colleague once built a page that had 380Kb of VIEWSTATE. That will affect performance!
Multiviews can work great in minimalist settings, but don't do like I did early on and attempt to build the equivalent to a 15 page medical form all in one ASPX page using the MultiView. If you are building short and sweet panes your performance will not suffer as much, but you will eventually cross the threshold and your performance will go into the gutter.