Hi,

I am using MasterPages with ASP.NET. The main contstruct of my MasterPage is a table providing a header, menu panel, main content and footer. I would like the table to at least fill the whole screen height. I've found (thru Google) a way of determining the screen height. The only way I can adjust the height of the table is to do it from a Javascript function which is called from the Code-Behind Page_Load. All attempts doing this purely by Javascript have failed. Trouble is that this Code-Behind / Javascript solution stops the javascript alert (pop-up) function working. Would really appreciate some advice on this. Haven't included any code here in case this is a recognisable problem, but am happy to do so. Have done decades of client-server development but first time into proper web development.

Thanks,
UJD.

I think some more information is required so that the best course of action can be taken. Show us your code please. Please use BB code tags while posting source program.

[code]

.... [/code]

Take a look at forum rules.

Hi, I've stripped out the bulk of the code and kept only that which seems relevant. Hope this provides sufficient material for you to review. Thanks in advance.

MasterPage.aspx

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" 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>Vaishnav Sangh UK</title>
    <link rel="Stylesheet" type="text/css" href="MasterPage.css"/>
    <script type="text/javascript">
	.
	.
        // determine screen height
        function pageHeight() {
            return window.innerHeight != null ? window.innerHeight : document.documentElement 
				      && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body 
				      != null ? document.body.clientHeight : null;
        }
        function SetMainTableHeight(elementID) {
            document.getElementById(elementID).height = pageHeight();
        }

        function attachEventHandler(element, eventToHandle, eventHandler) {
            if (element.attachEvent) {
                element.attachEvent(eventToHandle, eventHandler);
            } else if (element.addEventListener) {
                element.addEventListener(eventToHandle.replace("on", ""), eventHandler, false);
            } else {
                element[eventToHandle] = eventHandler;
            }
        }        
        // attach resize event
        attachEventHandler(window, "onresize", function() { SetMainTableHeight('MainLayout'); });
   </script>
    <style type="text/css">
	.
	.
    </style>
</head>

<body>
    <form id="form1" runat="server">
    <div align="center">
    <table id="MainLayout" cellpadding="5">
        <col />
        <col />
        <tr id="HeaderRow" valign="middle" style="background-color: #FF9900; height: 110px">
            <td id="HeaderCell" valign="middle" colspan="2">
		.
		.
            </td>
        </tr>
        <tr id="MainData">
            <td id="MainMenuCell" class="stMenuAll" valign="top" style="padding-left: 40px">
                <asp:Image runat="server" ImageUrl="~/Images/WidthSetterMenu.jpg" />
                <table class="stMenuAll" width="260px" align="center">
			.
			.
                    <tr>
                        <td id="mnuContact" class="stMenuLevel1"
                            onmouseover="MouseOverMenuHighlight('mnuContact')" onmouseout="MouseOutMenuUnHighlight('mnuContact')">
                            <a href="ContactUs.aspx">Contact</a>
                        </td>
                    </tr>
			.
			.
                </table>
            </td>
            <td id="MainContentCell" style="background-color: #FEF5E2">
                <asp:ContentPlaceHolder ID="MainContent" runat="server">
                </asp:ContentPlaceHolder>
            </td>
        </tr>
        <tr>
            <td colspan="2" class="stFooter" style="height: 60px">
                <table width="100%">
                    <tr>
			.
			.
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    </div>
    </form>
</body>

</html>

MasterPage.cs
It works if I remove the call to SetMainTableHeight

protected void Page_Load(object sender, EventArgs e)
    {   
	.
	.
        // set main table height
        Page.ClientScript.RegisterStartupScript(typeof(Page), "test", "<script>SetMainTableHeight('MainLayout');</script>");
	.
	.
    }

Contact.cs
Alert that has stopped working

protected void cmdSubmit_Click(object sender, EventArgs e)
    {
	.
	.
     	// confirm ok
        ClientScript.RegisterStartupScript(typeof(Page), "test", "<script>alert('Your message has been sent and copied to the email address supplied');</script>");        
	.
	.
    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.