MVC :: Sharing Same Master Page For Traditional Project
Feb 4, 2010
We have two projects. One is in MVC and the other is the traditional Asp.Net project. We are trying to share a common Master Page for both the projects. The Master page for the MVC project is already using a form tag with runat="server" attribute because it's using a traditional ASP.Net control for the navigation menu. The ContentPlaceHolder is outside this form.
UPDATE:
Found the answer here:
[URL]
<form
id="Form1"
runat="server">
.......
<asp:ContentPlaceHolder
ID="MainContent"
runat="server" />
</form>
View 2 Replies
Similar Messages:
Feb 12, 2010
For those who setup muli project areas in ASP.NET MVC 2 in VS 2010, I have a few questions for you:
Can other project areas use one master page? Or does each have to have their own master page?
What about the web.config file? Does each area need the config file? Or does it rely on the master?
I tried removing the master page reference, but I get an intellisense error and failed to monitor changes after following this: [URL]
I assume I need to leave in the master page so that at least works.
View 1 Replies
Jun 20, 2010
i have been recently requested from a client to upgrade his static html web site (hosted from another provider) to a new asp.net mvc web application (hosted from my provider). The current home page rank is 3/10 and i woul not like to lose it ehwn transferring the hosting DNS to another hosting provider company.
Is it possible to keep the home page rank? I am realy not interested in all the other pages.
Also, my home page can be accessed via [URL] disadvantage when comes to SEO?
View 5 Replies
Sep 20, 2010
I work in a small developing team with 3 developers and none of us are really 'uber elite programmers' but we get by pretty well for our company. One thing that has been constantly recurring is we keep using the same resources in multiple projects. One example being the fckeditor control, however it stinks to constantly add this folder to every project (I've got the control set-up in my toolbox, but it won't be able to find the code unless you have the folder in there). This also applies with constantly recurring master pages and controls. Now we have made some steps for improving this, including making a 'back end' project where we put our shared functions, and made a CDN for images and scripts. But I still run into issues. For instance all developers must make sure they have the latest version of the back end project checked out, and built. Also when you add a reference to that .dll, the paths have to be the same between developers, otherwise it breaks the reference.
Now I just found out you can add a project reference, which will make the back end project build anytime I build the front-end project, but again you still have to make sure you have the latest version checked out. But I wonder what else I could do? Things I find annoying are making sure the relative locations of the back end project to the front end project has to be the same, and making sure they have the latest version of the back end checked out. Are there better ways to do this?Also the back-end project is a class library, but how can I share resources like a user control? I tried putting a user control in a normal project, and then adding that project as a reference, but it doesn't give you access to the control in the file list like I am used to for dragging into a page.
View 2 Replies
Aug 17, 2010
looking for information on how to do this. our company has one website, with several different applications. the way we have set it up is that we have been creating these different applications as websites, we have one Master page for the whole site, so when we create a new website we also create a virtual site with our master page in it. We are using VS 2008 now and what we want to do is make the change to creating web applications but I have not been able to figure out how to bring our master pages into the application, without bringing the actual pages into the app. the only thing I have been finding is people creating the master page file in the web application, that will not work for us, as we have to many applications and if there is a change in the master page it has to show on our whole website, so we need to either be able to bring our master page in as another project or set it up as a virtual directory, or reference it in the web.cofig somehow, but the master page needs to stay in it's own directory and only referenced.
View 7 Replies
Feb 25, 2011
I am trying to add a .aspx page in the project , but while adding the .aspx page i am not getting the option to choose existing master pages. I remember long back i used to get that option to select the master page.
View 2 Replies
Mar 7, 2011
My team is creating several solutions to develop separate branches of the same site. We have some CSS, partials, and master view files that we would like to somehow share between solutions. I have tried linking files but that has to be done for each and every file (cannot link directories, it seems). Does anyone have a tried and true system for doing this sort of thing for larger sites (other than putting everything in one massive solution)?
View 1 Replies
Oct 17, 2010
how can i add title and meta tags for content pages in a project base on master and content page(dinamically) ?
i used the blow method for master page :
[code]....
and the error is :(in line *)
Error 17 'System.Web.UI.MasterPage' does not contain a definition for 'SetMetaTags' and no extension method 'SetMetaTags' accepting a first argument of type 'System.Web.UI.MasterPage' could be found (are you missing a using directive or an assembly reference?)
View 3 Replies
Jun 2, 2010
I have a MasterPage project which is a class library project (it includes themes, style sheets, menus etc) and all applications use them.
I am using the BasePage concept for dynamically adding title,meta tags and descriptions. This BasePage Class inherits system.UI.Page and the aspx pages in the project inherits the BasePage class.
Now i need to move this BasePage class from my application to the Master Page Project so that all the projects/applications can reuse the same code.
I tried add the basepage.cs in the App_code folder and tried calling it in the page directive like below
<%@
Page
Language="C#"
MasterPageFile="~/Master/Layout/MasterPage.master"
AutoEventWireup="true"
CodeBehind="xxxx.aspx.cs"
CodeFile="xxxx.aspx.cs"
Inherits="xxxx"
ValidateRequest="false"
EnableEventValidation="false"
ViewStateEncryptionMode="Never"
CodeFileBaseClass="~/Master/App_Code/BasePage<Page>"
Title="Title"
Meta_Keywords="xxxx,yyyy,zzzz"
Meta_Description="This is a test" %>
But i am getting error
Could not load type '~/Master/App_Code/BasePage<Page>'.
This was working fine till the BasePage class was inside the application. But once i moved it out of the project and added it to the master page project i getting this error.
View 3 Replies
Sep 27, 2010
I trying to run my project and I get the following error 'lstpreferredtheme_selectedindexchanged is not a member of ASP.Masterpages_Masterpage_master Even I've named the id of my dropdown list lstpreferredtheme which I trying to call. My code is below
<%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div id="PageWrapper">
<div id="Header"> <a href="~/" runat="server">Header Goes Here</a></div>
<div id="MenuWrapper">
Menu Goes Here</div>
<div id="MainContent">
<asp:ContentPlaceHolder ID="cpMainContent" runat="server">
</asp:ContentPlaceHolder>
</div>
<div id="Sidebar" title="Select A Theme">
<p>Select A Theme</p> <asp:DropDownList runat="server" AutoPostBack="True"
Height="16px" Width="101px"
onselectedindexchanged="lstPreferredTheme_SelectedIndexChanged"
ID="lstPreferredTheme" DataTextField="Select A Theme">
<asp:ListItem>Monochrome</asp:ListItem>
<asp:ListItem>Dark Grey</asp:ListItem>
</asp:DropDownList>
</div>
<div id="Footer">
Footer Goes Here</div>
</div>
</form>
</body>
</html>
Masterpage vb code
Partial Class MasterPage
Inherits System.Web.UI.MasterPage
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstPreferredTheme.SelectedIndexChanged
Dim preferredTheme As HttpCookie = New HttpCookie("PreferredTheme")
preferredTheme.Expires = DateTime.Now.AddMonths(3)
preferredTheme.Value = lstPreferredTheme.SelectedValue
Response.Cookies.Add(preferredTheme)
Response.Redirect(Request.Url.ToString())
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Dim selectedTheme As String = Page.Theme
Dim preferredTheme As HttpCookie = Request.Cookies.Get("PreferredTheme")
If preferredTheme IsNot Nothing Then
selectedTheme = preferredTheme.Value
End If
If lstPreferredTheme.Items.FindByValue(selectedTheme) IsNot Nothing Then
lstPreferredTheme.Items.FindByValue(selectedTheme).Selected = True
End If
End If
End Sub
End Class
View 4 Replies
Dec 1, 2010
I see on the bottom of blog pages a sharing buttons (Twitter and Facebook), where if clicked the link behind (which is normally the blog page url) the fshare button takes the clicker to the blog site facebook page respectively.
How does one do this in asp.net 2 , does one one use the <%# %> in the url part of these share buttons, are there any examples of how this is done?
View 8 Replies
Aug 17, 2010
I would like to start a debate on traditional repositories versus one built on the UnitOfWork pattern. In a traditional repository, we wrap inserts, updates and deletes in a transaction, but selects don't really need them. In addition, nhibernate configuration is typically done once per application due to BuildSessionFactory being rather expensive. We often have several repositories of this type (one per aggregate chain). We also need to have projected, ahead of time, exactly what kinds of queries we'll need in order to build the interfaces and concretes correctly. In a single UnitOfWork repository we have the ability to manage both the current session and transaction, perform several operations, and then commit any changes all at once. In such a repository we may opt to put our configuration in the constructor since (typically speaking) no more than one Action is called per request anyway, initializing it in the application doesn't seem like much of an overall gain in speed. I must admit, I'm very temped to use the UnitOfWork pattern, as the following code looks really nice to me:
Csharp Code:
using (IUnitOfWork worker = new UnitOfWork()){// session and transaction are now both set
// save changes to three itemsworker.SaveOrUpdate(item1);worker.SaveOrUpdate(item2);worker.SaveOrUpdate(item3);
// grab a fourth var item4 = worker.Criteria<Foo>().Add(Expression.Eq("title", title)).UniqueResult<Foo>();
// delete the fourthworker.Delete(item4);
// all pending operations are commited or rolled back as a single unit (if one fails, all are rolled back), and then disposed, along with the session}
My proposed UnitOfWork class is rather simple. It implements IDisposable where I use a try-catch-finally in Dispose() to attempt a tx.Commit(), doing a tx.Rollback on failure, and a cleaning everything up in the finally clause. It also exposes common things like SaveOrUpdate, Delete, GetAll, Get, and even a Critera<T>() for custom on-the-spot queries. So what are your thoughts on this? I'd really like to hear about your experience with this pattern.
View 4 Replies
Feb 10, 2010
It appears that xVal fits more into a MVC model. Can it be used for traditional Web forms model?
I am currently considering MS Validation block and .NET validation framework. What other validation frameworks can I look into?
View 1 Replies
Aug 2, 2010
I have a master page containing a tree and 3 dropdown lists. I am populating a context menu on right click of each node, and when clicked on any item of the context menu, it navigates to required pages.
My problem is after navigating to the required page, the selected values from the drop down lists and the selected node from the tree are getting cleared.
I can set the selected values for the dropdown lists by making some properties in master page.
But how do i maintain the selected node?
In my content page, i have got the valuepath of the right clicked node.
Or is there any other way than setting the properties in master page?
View 6 Replies
Jan 5, 2011
My Project is a normal web site, not a Web Project, and I am using VS 2005.
I am trying to define common Master Page Type in app_code which has an area to display error messages and the like. Very simple.
I added the following in app_code:
[Code]....
Also, I added the following in Master Page Source Declaration:
[Code]....
Also, I added the controls tblrowErrMsg and lblErrMsg as server controls to the Master Page.
Why I am doing this ?
This will allow me to display error messages from nearly any where inside the code in code-behined, app_code, and other core Class Projects (DLL).
View 4 Replies
Feb 3, 2010
Does [HandleError] attribute in MVC replaces the traditional try catch exception handling?
As I have seen codes in controllers where the top line of code is [HandleError] also I have not seen much of try catch in the code of the application I am working on.
View 2 Replies
Aug 2, 2010
How do you secure a WCF web service when you are using the traditional "connection string in the web.config"?
I have added a WCF service to an application which uses a JQuery post and returns JSON. The request happens on the client side. The purpose of this service is to return search information while the person is typing text into a textbox.
It works well, but there is a problem because the application will be used by a number of people and I am maintaining a role based security within the applications MS SQL database. The connection string to the database is in the web.config file.
In order to run the JQuery call to the web service the user must have at least read access directly to the database. I want to allow the application to control the access, but removing all security to the WCF service opens the application up for external access by unauthorized users.
View 3 Replies
Sep 5, 2010
I have a master page setup that is used throughout my site that is basically a header with a menu. I recently added a textbox and a button to this master page which is to be a quick search box that is available anywhere in the site. When a user enters text into the search box and hits the button, I need to load the actual content page which is used to search and show search results (which also uses this same master page), and have the text entered available so the search can be triggered automatically. Again, this search text box and button is now in my master page so it could be triggered from anywhere in the app... it serves as a convenient way to do a basic search from anywhere in my app, without having to first navigate to the actual 'search page' that already exists. You can also navigate to the actual search page, which uses the same master page, where there is many more search options.I'm thrown off by the master page arrangement, which I have not used until this project. What do I do?
View 4 Replies
Sep 29, 2010
Is it possible to inherit a sharepoint master page(as a parent) in another application's master page which will be treated as child (i.e. after integrating that standalone application with the sharepoint application)? I am totally new to Sharepoint..
View 2 Replies
Feb 18, 2010
I have a nested master page that has its own master page. The parent master page has a property defined in its code behind.
Public ReadOnly Property SelectedPage() As String
Get
Return _selectedPage
End Get
End Property
How can I reference the parent master page's property from within either the child master page's code behind Page_Load or aspx template page?
View 3 Replies
May 11, 2010
I have convert Classic ASP Project into .Net,
Now my requirement is that i have to give One link for Access Classic ASP Project.
For that I want link like
[URL]
Here [URL] is a virtual directory created for .Net Page. Now inside that i need to create one folder "OLDSITE" and inside oldside i need to put classic asp page.
How can i set virtual directory for classic asp page.
View 4 Replies
May 16, 2010
I am trying to deploy an ASP.NET 3.5 Web Application to my production server and I am using the Web Deployment Project for this purpose. I have a folder named MasterPages in the root of the application which contains all the master page files. When I build this project in the release mode and deploy it on to the server I am getting the below error message:
Directory 'C:inetpubwwwrootMasterPages' does not exist. Failed to start monitoring file changes.
I am using ASP.NET AJAX and the ToolkitScriptManager is on the master pages. I have noticed that the MasterPages folder is missing from the release build.
View 1 Replies
May 30, 2010
I'm trying to dynamically change the look of my main master page depending on what nested master page that the current content page is using .
So for example.
Main master page = main.master
My nested page = nested.master (uses main.master)
content page = content.aspx (uses nested.master)
So in the Page_Load event of main.master I want to add a switch statement that will check to see what nested master page is currently being used by content.aspx, or whatever content page is loaded.
So far I have got
protected void Page_Load(object sender, EventArgs e)
{
string nMaster = //This is the line of code that I am looking for.
switch(master)
{
case "nested.master":
//all my logic here.
break;
}
}
View 4 Replies
Sep 29, 2010
I have a 3 level nested master pages and a content page. parent1 is the top parent, parent2 is parent of parent3 and parent3 is the parent of the content page.
I get an error 'Cannot find ContentPlaceHolder xxx...' where xxx is a ContentPlaceholder. It resides in parent2 and content page is trying to fill it.
Can content pages only use their direct parent ContentPlaceHolders or can they also use any of the higher master pages?
View 2 Replies
Sep 16, 2010
How to access controls in master page using javascript? The master page consists of a search textbox, on key down event of the control I call a javascript function writtern inline of the master page. I get the value of entered in textbox in that javascript function. I have tried giving document.getElementById("<%=txtSearch.ClientID %>").value as well as document.getElementById("txtSearch").value. Both display error. I have to access the textbox control from within the master page itself!
View 1 Replies