ASP.NET Master Page on file in folder(s) - asp.net

I have a small problem with an ASP page. I have a master file and it works great on all pages in the ROOT; however, if I create a folder (say: reports and folder insider there called userRpts) and add a page, the master doesn't apply.
So, I have a fodler structure like:
/reports/UserRpts/UserData.aspx
Master is set as: MasterPageFile="~/MasterPage.master" in the <%# Page %>
Yet it doesn't apply. Any thoughts?

Related

In an aspx file where does the actual code gets loaded?

So this code is in a file login.aspx which literally has some html mnarkup and the below code, so where does this code get loaded from? Where is the App_Web_login.aspx.d7a6dcf1 file located ?
<%# page language="C#" autoeventwireup="true" inherits="stadm_login,
App_Web_login.aspx.d7a6dcf1" enableeventvalidation="false" theme="Niko" %>
The code is contained in a file that is associated with its page. In Visual Studio if you load the project you will see a caret next to the aspx page. Click that and you will see a file associated with that page. That is the code file, or code behind, for the login page.
When the project is built, the code for each page is wrapped into a dll file or code package for the entire project. What you see for the inherits in the page is the base class for the project and also the inheriting of the page class.
So if my project is called FooProject, then at the top of each page where it says inherits, you will something like this (the _base class .page class):
inherits=_FooProject.Login

Updating a DLL in an aspx

I am an old ASP programmer that recently took a job that has ASP.NET. I have an aspx file that has this at the top:
<%# Page Title="" Language="C#" MasterPageFile="~/Default.Master" AutoEventWireup="true"
CodeBehind="List.aspx.cs" Inherits="itnola.List" %>
And the area that I'm most interested in is this line of code:
<asp:DropDownList ID="dplDistrict" runat="server" Width="205" DataValueField="districtID"
DataTextField="districtname">
There is a table in the database called districts that if I make a modification to that table it displays the changes in this dropdown. However, there is an extra entry in the drop down I assume they have hardcoded.
Not being familiar with ASP.NET, I've looked for a List.aspx.cs file and do not find it anywhere on the server. I did find an itnola.dll file in a bin folder I suspect may have something to do with this. If I remember correctly from my Visual Basic days this dll file is "compiled" and therefore not editable correct? How do I remove this one line in the drop down?

How to force update .ascx file content in Website project

I have Website project, which contains some .ascx and .aspx files. I have added new element <asp:TextBox ID="tb1" runat="server" ... /> in .ascx file and I have wrote some code in proper .ascx.cs file using this element: tb1.Text = "SomeText";. When I compile this project I recieve following error: The name 'tb1' does not exist in the current context.
How can I force to refresh markup of .ascx page? I use Website project and I cannot to change its type to Webapplication.
UPD: I have Website project, which has NOT .ascx.designers.cs files. And I cannot change type of my project to web application.
Unless there's something else happening here, it sounds like the designer.cs file might be out of sync. Try cutting and pasting the control back into the markup, or go into the designer file for the user control and add the TextBox manually:
protected global::System.Web.UI.WebControls.TextBox tb1;
It seems like your design file is not connecting with your code behind file.
Can you confirm if you are defining it as follows,
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="yourcontrol.ascx.cs" Inherits="CompleteNameSpace.ClassName" %>

Unable To See Master Pages While Adding A Page In The Project

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.
Don't know why it is not visible; if you cannot set it, simply add it later manually to the #Page directive of your page.
It's simple:
MasterPageFile="~/Path/To/My/MasterPage.master"
E.g. on top of your ASPX page, write something like:
<%# Page
Culture="auto"
UICulture="auto"
MaintainScrollPositionOnPostback="true"
Title="The Title of your Page"
Language="C#"
MasterPageFile="~/Path/To/My/MasterPage.master"
AutoEventWireup="true"
CodeFile="MyPage.aspx.cs"
Inherits="MyPage"
%>
In addition, if you want to access the derived type of your master page, use the #MasterType directive:
<%# MasterType VirtualPath="~/Path/To/My/MasterPage.master" %>
Could be a bug with VS, try save the project with your master page then close and reopen VS.
If not as Uwe Keim mentioned above it is really easy to add the master page manually.

how to apply master page to pages in asp.net 2008

I am using .net 2008 for developing web application.
So I created a master page and some other pages. I want to apply master page to all other pages but I'm not getting it. Earlier i use .net2005 here there is option when we created a new page in application and check the master page option, but in .net2008 this option is not there so please tell me how to do it. I'm new to .net 2008 .
Please tell me
Thank you
If you want to manually set the masterpage for pages you have already created you can do the following: In the Page directive of your ASPX pages you set the masterpage like this:
<%# Page Language="C#" MasterPageFile="~/MasterPages/Master1.master" Title="Content Page"%>
Your MasterPage defines a few Content areas. You then should reuse those in your page and fill them with the local content.
When adding a new page the documentation says that when adding a Web Forms page you can select the Select master page check box, and then click Add. Then the Select a Master Page dialog box should appear.
You indicating that in your question
"when we created a new page in application and check the master page option"
If you are using a web application when you wan't to add a page with masterpage
you should add the page like this
Project ->
Add New Item ->
Web Form Using Master Page (instead of selecting Web Form)
Then you will have the option to select the masterpage
Use this code:
<%# Page Title="test" Language="VB" MasterPageFile="~/MasterPageName.master" AutoEventWireup="false" CodeFile="PageName.aspx.vb" Inherits="PageNameClass" %>
<asp:Content ID="Content1" ContentPlaceHolderID="maincontent" runat="Server">
//here you can add you page data start from form tag till end of form tag and remove everything else.
</asp:Content>

Resources