Img上的弹出日历单击消失 [英] Popup Calendar on Img click disappearing
本文介绍了Img上的弹出日历单击消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我有一个asp日历控件,点击img标签时可以看到,但是如果我改变月份,日历控件就会消失。你可以帮忙吗。
参考代码:
Hi All,
I have a asp calendar control which is visible on click of img tag but, the calendar control is disappearing if i change the month . can u please help on this.
Referenc code:
function popupCalendar() {
// toggle the div
if (document.getElementById('<%=dateField.ClientID%>').style.display == 'none')
document.getElementById('<%=dateField.ClientID%>').style.display = 'block';
else
document.getElementById('<%=dateField.ClientID%>').style.display = 'none';
}
<td>
<asp:TextBox ID="txtCalenderStart" runat="server" Width="140px" /><asp:Label ID="lblrepStart"
runat="server" Visible="false"></asp:Label>
<img alt="calender" onclick="popupCalendar()" src="/_layouts/images/calendar.jpg" />
</td>
<td id="dateField" style="display: none;" runat="server" class="style3">
<asp:Calendar ID="calStartDate" OnSelectionChanged="calStartDate_SelectionChanged"
runat="server" />
</td>
推荐答案
试试这个:
Try this:
<script type="text/javascript">
function popupCalendar()
{
var dateField = document.getElementById('dateField');
if (dateField.style.display == 'none')
dateField.style.display = 'block';
else
dateField.style.display = 'none';
}
</script>
<body>
<form id="form1" runat="server">
<asp:TextBox
id="txtDate"
Runat="server" />
<img src="Images/btnadd.png" alt="s" onclick="popupCalendar()" />
<div id="dateField" style="display:none;">
<asp:Calendar id="calDate"
OnSelectionChanged="calDate_SelectionChanged"
Runat="server" />
</div>
<br />
/>
/>
</form>
</body>
代码落后
code behind
protected void calDate_SelectionChanged(object sender, EventArgs e)
{
txtDate.Text = calDate.SelectedDate.ToString("d");
}
这篇关于Img上的弹出日历单击消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文