[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 277
  • Last Modified:

doubt in aspx to master page

hi created a aspx without  checking master page......now i want that aspx page to support one master page created now...how can i do that....
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="abx.aspx.cs" Inherits="abc" %>
 
<!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 id="Head1" runat="server">
    <title>Untitled Page</title>
   </head>

Open in new window

0
Rajar Ahmed
Asked:
Rajar Ahmed
2 Solutions
 
Juan_BarreraCommented:
Hi meeran,
1) You need to put set the MasterPage in the Page declaration:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="abx.aspx.cs" Inherits="abc" MasterPageFile="~/MasterPage.master" %>
 
 2) You need to add the contents of your page to the asp:Contents placeholder:
<asp:Content ContentPlaceHolderID="ContentPlaceHolder1" > 
   Page contents here
</asp:Content>
Note that ContentPlaceHolder1 corresponds to the asp:ContentsPlaceHolder control that is your Master Page, and that you only need to add your markup to it (that is, excluding the headers, the body and form tags, et.
0
 
Rajar AhmedConsultantAuthor Commented:
when i put masterpage code...
my previous design of the page is not inheriting,,,,
Whether it cant be done . ??



0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
Snarf0001Commented:
It can be done, exactly as Juan Barrera said.
If it's not working, please post the full markup from the page.
0
 
Rajar AhmedConsultantAuthor Commented:
am getitin error, in below code when i  include masterpagefile,


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="hyderabad.aspx.cs" Inherits="hyderabad" MasterPageFile="~/RecipeMaster.master"%>
 
<!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 id="Head1" runat="server">
    <title>Untitled Page</title>
    <link href="style/sample.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
 
    <div id="container">
      <div>
    <div id="left">
    <h2 class="smallBlack"><span class="black2">SouthIndian Foods</span></h2>
    
    
                                      
    
    
    <div class="left1">
        <asp:Label ID="Label1" runat="server" Style="left: 9px; position: relative; top: 11px"
            Text="Select Your Restaurant" Width="145px"></asp:Label>
    
     <asp:DropDownList ID="DropDownList1" runat="server"  EnableViewState="true" AutoPostBack="True" DataSourceID="SqlDataSource1"
            DataTextField="resname" DataValueField="rid" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged1"
            Style="left: 31px; position: relative; top: 14px" AppendDataBoundItems="True">
         <asp:ListItem Value="0">Your Favourites Restaurant</asp:ListItem>
        </asp:DropDownList>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
            Style="left: 5px; position: relative; top: 26px" Width="314px" CellPadding="4" ForeColor="#333333" GridLines="None" >
            <Columns>
                <asp:BoundField HeaderText="Foodname" DataField="fname" />
                <asp:BoundField HeaderText="Price" DataField="price" />
               <asp:TemplateField HeaderText="Quantity">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:TextBox ID="TextBox2" runat="server" Style="position: relative"></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:ButtonField HeaderText="Buy" Text="AddtoCart" />
            </Columns>
            <RowStyle Wrap="True" BackColor="#EFF3FB" />
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <EditRowStyle BackColor="#2461BF" />
        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <AlternatingRowStyle BackColor="White" />
        </asp:GridView>
        &nbsp;
        <br />
        <br />
        
        
</div>
 <p class="greyText1">
    
       
        
    </div>
    </div>
    </form>
</body>
</html>

Open in new window

0
 
Snarf0001Commented:
You've only done Step 1 of Juan's instructions.
Once the master page has been declared in the tag, you still need to:

2) add the content holders - when you create the master page, there should be one or more <asp:Content> tags, that you have to match up.

3) remove the extra html.  the header / body / form tags are all NOT allowed in content forms.

If you're having problems, post the markup of the master page as well, and we can integrate it up for you.
0
 
Rajar AhmedConsultantAuthor Commented:

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="RecipeMaster.master.cs" Inherits="RecipeMaster" %>
 
<!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>
    <link href="style/sample.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <div>
        &nbsp;<table cellpadding="12" style="left: 0px; width: 100%; height:307px; position: relative;
            top: 0px; height: 138px">
            <tr>
                <td colspan="2">
                </td>
                <td rowspan="3" style="width: 100px;">
                    <asp:HyperLink ID="HyperLink1" runat="server" Style="position: relative" >great</asp:HyperLink><br />
                    <asp:HyperLink ID="HyperLink2" runat="server" Style="position: relative" >real</asp:HyperLink>
                    <asp:HyperLink ID="HyperLink3" runat="server" Style="position: relative; left: 4px; top: 17px;" >fantatc</asp:HyperLink><br />
                    <asp:HyperLink ID="HyperLink4" runat="server" Style="position: relative; left: 1px; top: -19px;">maghi</asp:HyperLink>
                    <asp:HyperLink ID="HyperLink5" runat="server" Style="position: relative" >Ragj</asp:HyperLink>
                    <asp:HyperLink ID="HyperLink6" runat="server" Style="position: relative" >Zebj</asp:HyperLink>
                    <asp:HyperLink ID="HyperLink7" runat="server" Style="position: relative" >Readh</asp:HyperLink>
                    <asp:HyperLink ID="HyperLink8" runat="server" Style="position: relative" >Nalfs</asp:HyperLink></td>
            </tr>
            <tr>
                <td colspan="2" style="height: 85px">
                    <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
                    </asp:ContentPlaceHolder>
                </td>
            </tr>
            <tr>
                <td style="height: 42px;" colspan="2">
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>

Open in new window

0
 
Rajar AhmedConsultantAuthor Commented:
I need to combine this page with that master page...

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Chinese.aspx.cs" Inherits="Chinese" %>
 
<!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 id="Head1" runat="server">
    <title>Untitled Page</title>
    <link href="style/sample.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
  
    <div id="container">
      <div>
    <div id="left">
	<h2 class="smallBlack"><span class="black2">SouthIndian Foods</span></h2>
	
	<p class="greyText1">the name of South India, particularly Tamil Nadu, brings to ones mind the tastes of Idlis, dosas, Sambhar 
                                      and Vada. However, there are more than these 
                                      that can treat the taste buds. Most of the 
                                      vegetarian and non-vegetarian dishes of 
                                      this region have a generous use of spices 
                                      and coconuts.</p>
                                      
	
	
	<div class="left1">
        <asp:Label ID="Label1" runat="server" Style="left: 9px; position: relative; top: 11px"
            Text="Select Your Restaurant" Width="145px"></asp:Label>
	
	 <asp:DropDownList ID="DropDownList1" runat="server"  EnableViewState="true" AutoPostBack="True" DataSourceID="SqlDataSource1"
            DataTextField="resname" DataValueField="rid" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged1"
            Style="left: 31px; position: relative; top: 14px" AppendDataBoundItems="True">
         <asp:ListItem Value="0">Your Favourites Restaurant</asp:ListItem>
        </asp:DropDownList>
		<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            Style="left: 5px; position: relative; top: 26px" Width="314px" CellPadding="4" ForeColor="#333333" GridLines="None" >
            <Columns>
                <asp:BoundField HeaderText="Foodname" DataField="fname" />
                <asp:BoundField HeaderText="Price" DataField="price" />
               <asp:TemplateField HeaderText="Quantity">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:TextBox ID="TextBox2" runat="server" Style="position: relative"></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:ButtonField HeaderText="Buy" Text="AddtoCart" />
            </Columns>
            <RowStyle Wrap="True" BackColor="#EFF3FB" />
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <EditRowStyle BackColor="#2461BF" />
        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <AlternatingRowStyle BackColor="White" />
        </asp:GridView>
        &nbsp;
        <br />
        <br />
		
		
</div>
 <p class="greyText1"> South Indian dishes are mostly rice-based, sambhar,
rasam and curries being important side dishes. Rice is combined with
lentils to make wondrous dosas, idlis, vadas and uttapams. These food
items are glorious and delicious besides the fact that they are rich in
nourishment and easily digestible (due to the fermenting process). They
are combined with sambhar (dal), rasam (tamarind dal), dry and curried
vegetable and pachadi (yogurt). 
 </p>
</div>
    
       
        
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:tonivtreepConnectionString %>"
            SelectCommand="SELECT [resname], [rid] FROM [resttable] where hid =99  "></asp:SqlDataSource>
    
       
        
    </div>
    </div>
    </form>
</body>
</html>

Open in new window

0
 
Snarf0001Commented:
Okay, so basically, IF you were creating a new page, it would come up with the header tag like you have, and the only thing on the page would be this:

<%@ Page Title="" Language="C#" AutoEventWireup="true"........ %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
</asp:Content>

and all of the markup has to go between that contentplaceholder.
In your page, you would be taking everything BETWEEN the form tags, and putting in there.  So basically you're exluding all markup outside and including the form tags.

See the code below, just to reiterate, notice that there are no html, body or form tags in the entire file.
<%@ Page Title="" Language="C#" AutoEventWireup="true" MasterPageFile="~/RecipeMaster.Master" CodeBehind="Chinese.aspx.cs" Inherits="Chinese" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
  
    <div id="container">
      <div>
    <div id="left">
	<h2 class="smallBlack"><span class="black2">SouthIndian Foods</span></h2>
	
	<p class="greyText1">the name of South India, particularly Tamil Nadu, brings to ones mind the tastes of Idlis, dosas, Sambhar 
                                      and Vada. However, there are more than these 
                                      that can treat the taste buds. Most of the 
                                      vegetarian and non-vegetarian dishes of 
                                      this region have a generous use of spices 
                                      and coconuts.</p>
                                      
	
	
	<div class="left1">
        <asp:Label ID="Label1" runat="server" Style="left: 9px; position: relative; top: 11px"
            Text="Select Your Restaurant" Width="145px"></asp:Label>
	
	 <asp:DropDownList ID="DropDownList1" runat="server"  EnableViewState="true" AutoPostBack="True" 
            DataTextField="resname" DataValueField="rid" 
            Style="left: 31px; position: relative; top: 14px" AppendDataBoundItems="True">
         <asp:ListItem Value="0">Your Favourites Restaurant</asp:ListItem>
        </asp:DropDownList>
		<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            Style="left: 5px; position: relative; top: 26px" Width="314px" CellPadding="4" ForeColor="#333333" GridLines="None" >
            <Columns>
                <asp:BoundField HeaderText="Foodname" DataField="fname" />
                <asp:BoundField HeaderText="Price" DataField="price" />
               <asp:TemplateField HeaderText="Quantity">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:TextBox ID="TextBox2" runat="server" Style="position: relative"></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:ButtonField HeaderText="Buy" Text="AddtoCart" />
            </Columns>
            <RowStyle Wrap="True" BackColor="#EFF3FB" />
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <EditRowStyle BackColor="#2461BF" />
        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <AlternatingRowStyle BackColor="White" />
        </asp:GridView>
        &nbsp;
        <br />
        <br />
		
		
</div>
 <p class="greyText1"> South Indian dishes are mostly rice-based, sambhar,
rasam and curries being important side dishes. Rice is combined with
lentils to make wondrous dosas, idlis, vadas and uttapams. These food
items are glorious and delicious besides the fact that they are rich in
nourishment and easily digestible (due to the fermenting process). They
are combined with sambhar (dal), rasam (tamarind dal), dry and curried
vegetable and pachadi (yogurt). 
 </p>
</div>
    
       
        
       
        
    </div>
    </div>
    
</asp:Content>

Open in new window

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now