tags:

views:

66

answers:

3

I am developing a C#/SQL VS 2008 website application and I'm trying to set breakpoints in my site.master file--is there a way to do this? The contents of this file are:

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="Site" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head id="Head1" runat="server">
    <title>Forms Authentication, Authorization, and User Accounts</title>
    <link href="Styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <div id="wrapper">
        <form id="form1" runat="server">
        <div id="header">
            <span class="title">User Account Tutorials</span><br />
            <span class="breadcrumb">
                <asp:SiteMapPath ID="SiteMapPath1" runat="server">
                </asp:SiteMapPath>
            </span>
        </div>
        <div id="content">
            <asp:ContentPlaceHolder ID="MainContent" runat="server">
                <!-- Page-specific content will go here... -->
            </asp:ContentPlaceHolder>
        </div>
        <div id="navigation">
            <asp:ContentPlaceHolder ID="LoginContent" runat="server">
                <asp:LoginView ID="LoginView1" runat="server">
                    <LoggedInTemplate>
                        Welcome back,<asp:LoginName ID="LoginName1" runat="server" />
                    </LoggedInTemplate>
                    <AnonymousTemplate>
                        Hello, stranger!
                    </AnonymousTemplate>
                </asp:LoginView>
                <br />
                <br />
            </asp:ContentPlaceHolder>
            <asp:LoginStatus ID="LoginStatus1" runat="server" LogoutAction="Redirect" LogoutPageUrl="~/Logout.aspx" />
            <ul>
                <li>
                    <asp:HyperLink runat="server" ID="lnkHome" NavigateUrl="~/Default.aspx">Home</asp:HyperLink>
                </li>
                <asp:Repeater runat="server" ID="menu" DataSourceID="SiteMapDataSource1">
                    <ItemTemplate>
                        <li>
                            <asp:HyperLink ID="lnkMenuItem" runat="server" NavigateUrl='<%# Eval("Url") %>'><%# Eval("Title") %></asp:HyperLink>

                            <asp:Repeater ID="submenu" runat="server" DataSource="<%# ((SiteMapNode) Container.DataItem).ChildNodes %>">
                                <HeaderTemplate>
                                    <ul>
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <li>
                                        <asp:HyperLink ID="lnkMenuItem" runat="server" NavigateUrl='<%# Eval("Url") %>'><%# Eval("Title") %></asp:HyperLink>
                                    </li>
                                </ItemTemplate>
                                <FooterTemplate>
                                    </ul>
                                </FooterTemplate>
                            </asp:Repeater>
                        </li>
                    </ItemTemplate>
                </asp:Repeater>
            </ul>
            <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="false" />
        </div>
        </form>
    </div>
</body>
</html>

My site.master.cs file contents:

public partial class Site : System.Web.UI.MasterPage { protected void Page_Load(object sender, EventArgs e) {

}

}

+1  A: 

You should put the breakpoint in your code behind. i.e. PageLoad.

So in your case the code behind file is: Site.master.cs

The code behind of my masterpages are mostly empty (like you have). Its main purpose is to define your website's structure and it contains the place holders for you "real content".

Scenarios where you might want to put some logic in your Master page's code-behind is for instance when you want to generate a Google-maps javascript (coming from the database) at the bottom of every page of your website.

Sander Pham
Yes, I did but currently this is empty. See updated description.
salvationishere
It's empty right now, but this is the place where you should put your UI logic/presentation code
Sander Pham
@Sander, can you expound on this?
salvationishere
+1  A: 

You can set breakpoints in the code-behind, and javascript debugging will be as good (or bad) as always. The master page is just another aspx page; nothing differs.

Cylon Cat
OK, I set a breakpoint in the PageLoad code behind, but this is currently empty. What code can I add to this to debug the ASPX file?See updated description.
salvationishere
The question is, what is it about the master page that you want to debug? Everything in your master page is markup, not executable code. If there are problems with markup, Visual Studio will give errors and warnings, or you can try a tool such as Resharper, which will give you lots of additional diagnostics.
Cylon Cat
A: 

You can put breakpoint at the first '{' of the PageLoad method.

alt text

Soe Moe
Yes, it enters this method. But what can I put in the Page_Load?
salvationishere