Question

i need a little explanation about how master page works (maybe it also call asp.net master page life cycle). lets consider i have three page that linked to one master page. The Code looks like this :

    <asp:table runat="server" ID="tableFrame" CssClass="table">
        <asp:TableHeaderRow CssClass="atas">
            <asp:TableHeaderCell ColumnSpan="2">
                Master Page <br />
                Tutorial
            </asp:TableHeaderCell>
        </asp:TableHeaderRow>
        <asp:TableRow>
            <asp:TableCell CssClass="samping">
                <a href="index.aspx">Homepage</a> <br />
                <a href="Simple_Calculator.aspx">Simple Calculator</a> <br />
                <a href="Asterik_Triangle.aspx">Asterik Triangle</a>
            </asp:TableCell>
            <asp:TableCell CssClass="isi">                    
                <asp:ContentPlaceHolder ID="Content" runat="server">

                </asp:ContentPlaceHolder>
            </asp:TableCell>
        </asp:TableRow>
        <asp:TableFooterRow CssClass="bawah">                
            <asp:TableCell ColumnSpan="2">
                &copy; Web Technology
            </asp:TableCell>
        </asp:TableFooterRow>
    </asp:table>

Index code look like this :

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Index.aspx.cs" Inherits="index" Title="Homepage" MasterPageFile="~/Master.master"  %>

<asp:Content ID="Head_Index" ContentPlaceHolderID="head" runat="server">

</asp:Content>

<asp:Content ID="Content_Index" ContentPlaceHolderID="content" runat="server">
    Welcome to Our Homepage <br />
    Please follow the instruction to finish the construction of this website
</asp:Content>

Its asp.net works like AJAX?

just keep in mind AJAX not reload all page, just what it needed to reload, maybe in this case is in index.aspx (maybe asp.net not reload file *.master, just index.aspx and show it in .net Object contentPlaceHolder) and while web applications send data to, and retrieve data from, a server asynchronously (in the background) without interfering with the display and behavior of the existing page.

Thanks for your advice. Cheers! :)

Was it helpful?

Solution

No, there's no AJAX in the code you posted.

Master pages and content pages are entirely server-side concepts. The client (browser) has no knowledge of them. The server-side code (the ASP.NET Framework in this case) assembles components when responding to a request, building an output stream to send to the client.

In this case that assembling of components includes executing the server-side code, "merging" the master page and content page, interpreting the various server-side controls and data bound to them into client-side HTML/JavaScript, and building one big string to send to the client as the rendered HTML.

It does this on every request for a page. When you open the page in your browser, go to View Source to see the "string" that was output from the server-side code. You'll see that it's all one page, there's no client-side distinction between master pages and content pages.

OTHER TIPS

No, a Master Page is not "like AJAX" in any sense. It's simply a way of abstracting out parts of your page's markup that don't change from page to page. That way the markup on the page can focus on what is important to the page. It's similar in purpose to "Server Side Includes" in a way, if you're familiar with those. But the mechanism is very different because it happens entirely on the server side.

By the way, text on .aspx and .master pages is not considered code. It's markup. Stuff on .cs or .vb pages is considered code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top