我正在尝试向现有页面添加母版页以创建站点范围的标题。不幸的是,当我向Default.aspx
添加母版页引用时,一些Javascript大小控件停止工作function ChangePanelHeight(){
var MyPanel;
var NewHeight=(screen.height*.45);
MyPanel = document.getElementById('pnlContainer');
MyPanel.style.height = NewHeight + "px";
}
当我添加母版页时,javascript函数(嵌入在内容页面上)可以正常工作,但是调整大小时却没有。换句话说,javascript中的alert('Hey!');
触发得很好,但由于某种原因,面板高度保持不变。没有它,它工作正常。母版页如下所示:
<%@ Master Language="VB" AutoEventWireup="false" CodeBehind="Site.master.vb" Inherits="PropertyManagementSystem.Site" %>
<!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></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div id="header">
<table>
<tr>
<td><h1>Property Management System</h1></td>
</tr>
<tr>
<td><h2>All Your Property - Managed At The Palm Of Your Hand</h2></td>
<td><h2>Welcome <asp:Label ID="lblWhoName" runat="server"/></h2></td>
</tr>
<tr>
<td><a id="lHome" href="Default.aspx">Home</a></td>
<td><a id="lManageDevices" href="ManageDevices.aspx">Manage Devices</a></td>
<td><a id="lManageLookupTables" href="ManageLookups.aspx">Manage Lookups</a></td>
<td><a id="lHelp" href="Help.aspx">Help</a></td>
</tr>
</table>
</div>
<div>
<asp:ContentPlaceHolder ID="MainContent" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
答案 0 :(得分:0)
尝试此操作(使.getElementID的元素ID引用控件的客户端ID):
function ChangePanelHeight(){
var MyPanel;
var NewHeight=(screen.height*.45);
MyPanel = document.getElementById('<%=pnlContainer.ClientID %>');
MyPanel.style.height = NewHeight + "px";
}