我在网页中加入一个web用户控件,运行时控件js函数ShowMList总提示错误“缺少对象”,getElementById取不到值。
如何解决啊,请指教,多谢了!web控件如下:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl.ascx.cs" Inherits="WebUserControl" %>
<link href="MyStyles.css" type="text/css" rel="stylesheet" />
<script type="text/javascript">
var timoutID;
function ShowMList()
{
var divRefC = document.getElementById("divCheckBoxListClose");
divRefC.style.display = "block";
alert('aafdfdf');
}
function HideMList()
{
document.getElementById("divCheckBoxListClose").style.display = "none";
}
</script><asp:ScriptManager ID="smDefault" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="upDefault" runat="server">
<ContentTemplate>
<br />
<div id="divCustomCheckBoxList" runat="server" onmouseout="timoutID = setTimeout('HideMList()', 750);"
onmouseover="clearTimeout(timoutID);">
<table>
<tr>
<td align="left" class="DropDownLook">
<img id="imgShowHide" runat="server" alt="选择" align="left" onclick="ShowMList()" src="drop.gif" />
</td>
</tr>
<tr>
<td class="DropDownLook" colspan="2">
<div>
<div id="divCheckBoxListClose" runat="server" class="DivClose">
<label id="lblClose" runat="server" class="LabelClose" onclick="HideMList();" style="left: 213px;
bottom: 0px; width: 34px;">
确定</label>
</div>
</div>
</td>
</tr>
</table>
</div>
<br />
<div>
<asp:Button ID="btnSubmit" runat="server" OnClick="btnSubmit_Click" Text="Submit Selection" />
<br />
<br />
<asp:Label ID="lblTextSelected" runat="server" Font-Bold="true" Text=""></asp:Label>
</div>
</ContentTemplate>
</asp:UpdatePanel>
如何解决啊,请指教,多谢了!web控件如下:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl.ascx.cs" Inherits="WebUserControl" %>
<link href="MyStyles.css" type="text/css" rel="stylesheet" />
<script type="text/javascript">
var timoutID;
function ShowMList()
{
var divRefC = document.getElementById("divCheckBoxListClose");
divRefC.style.display = "block";
alert('aafdfdf');
}
function HideMList()
{
document.getElementById("divCheckBoxListClose").style.display = "none";
}
</script><asp:ScriptManager ID="smDefault" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="upDefault" runat="server">
<ContentTemplate>
<br />
<div id="divCustomCheckBoxList" runat="server" onmouseout="timoutID = setTimeout('HideMList()', 750);"
onmouseover="clearTimeout(timoutID);">
<table>
<tr>
<td align="left" class="DropDownLook">
<img id="imgShowHide" runat="server" alt="选择" align="left" onclick="ShowMList()" src="drop.gif" />
</td>
</tr>
<tr>
<td class="DropDownLook" colspan="2">
<div>
<div id="divCheckBoxListClose" runat="server" class="DivClose">
<label id="lblClose" runat="server" class="LabelClose" onclick="HideMList();" style="left: 213px;
bottom: 0px; width: 34px;">
确定</label>
</div>
</div>
</td>
</tr>
</table>
</div>
<br />
<div>
<asp:Button ID="btnSubmit" runat="server" OnClick="btnSubmit_Click" Text="Submit Selection" />
<br />
<br />
<asp:Label ID="lblTextSelected" runat="server" Font-Bold="true" Text=""></asp:Label>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<head runat="server">
<title>无标题页</title>
<link href="MyStyles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<uc1:WebUserControl ID="WebUserControl1" runat="server" />
</div>
</form>
</body>
</html>