一个TextBox,一个Calendar控件,我想当TextBox得到焦点时Calendar控件就隐藏起来,我下面的代码老是隐藏不了?C#:this.tbInHospitalDateBegin.Attributes.Add("onfocus", "calVisible(" + this.Calendar2.ClientID+ ")");js:
function calVisible(obj1) {
obj1.style.display="none";
//alert("1020");
}
不知道哪里写得不对??
function calVisible(obj1) {
obj1.style.display="none";
//alert("1020");
}
不知道哪里写得不对??
function hideCalendar(id) {
document.getElementById(id).style.display = "none";
}
</script>
试过了,不行,不知道哪里没写好,用alert("1020")放在hideCalendar()都有效果,就是 document.getElementById(id).style.display = "none"没有,不知跟ajax的updatepannel面板有没有关系,因为我放有updatepannel面板
<asp:Calendar ID="Calendar1" runat="server"
...
</asp:Calendar>
</div>div外层有UpdatePanel
<title></title>
<script type="text/javascript">
function hideCalendar(id) {
document.getElementById(id).style.display = "none";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>C#protected void Page_Load(object sender, EventArgs e)
{
TextBox1.Attributes.Add("onfocus", "hideCalendar('" + Calendar1.ClientID + "');");
}
.calender1
{
position:absolute;
left:44%;
top:20%;
}
function hideCalendar(id) {
$get(id).style.display = "none";
}
</script>
<title></title>
<script type="text/javascript">
function hideCalendar(id) {
$get(id).style.display = "none";
}
</script>
<style type="text/css">
.calender1
{
position:absolute;
left:44%;
top:20%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<div id="divcal1" class="calender1" runat="server">
<asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
C#和刚才一样.