Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

Have a problem while making hidden element visible using javascript and asp.net

$
0
0

I'm developing website using visual studio 2010 for my personal use. In that to select date, I'm using a calender which is lying inside <div> element. I have a textbox and image button where my intention is to display the calender to select date and store this date in textbox, on clicking image button. So what I do is, I hide the div element initially in CSS and make it visible on clicking image button. To make it visible, I have written Javascript function. The problem is, calendar will get visible on clicking image button and disappears as soon as I release(ie, visible for a second and disappears) the button, where I am not able to choose the date. find the code below.

<------------------- ASP.NET code--------------------------->

<asp:Label ID="Label13" runat="server" Text="Rectified date"></asp:Label>
&nbsp;&nbsp;&nbsp; <asp:TextBox ID="date_textbox" runat="server"></asp:TextBox>
<asp:ImageButton ID="ImageButton1" runat="server" Height="22px" ImageUrl="~/Images/calendar_icon.png" Width="25px"
onClientclick="ImageButton1_Click()" />
</p>
<div style="height: 223px; width: 219px; visibility: hidden; float: right; overflow: visible; clear: left; clip: rect(auto, auto, auto, auto); position: absolute;"
id="calendar" class="calendar">
<asp:Calendar ID="Calendar_div" runat="server" BackColor="White"
BorderColor="#3366CC" BorderWidth="1px" CellPadding="1"
DayNameFormat="Shortest" Font-Names="Verdana" Font-Size="8pt"
ForeColor="#003399" Height="200px" Width="220px"
onClientselectionchanged=""
style="margin-right: 28px">
<DayHeaderStyle BackColor="#99CCCC" ForeColor="#336666" Height="1px" />
<NextPrevStyle Font-Size="8pt" ForeColor="#CCCCFF" />
<OtherMonthDayStyle ForeColor="#999999" />
<SelectedDayStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
<SelectorStyle BackColor="#99CCCC" ForeColor="#336666" />
<TitleStyle BackColor="#003399" BorderColor="#3366CC" BorderWidth="1px"
Font-Bold="True" Font-Size="10pt" ForeColor="#CCCCFF" Height="25px" />
<TodayDayStyle BackColor="#99CCCC" ForeColor="White" />
<WeekendDayStyle BackColor="#CCCCFF" />
</asp:Calendar>
<asp:Button ID="Button1" runat="server" onClientclick="Button1_Click1"
Text="Done" onclick="Button1_Click1" />
</div>

<--------------------------------ASP.NET code--------------------------------->

javascript function for the same is:

<script type="text/javascript">

function ImageButton1_Click() {

var div_calendar = document.getElementById("calendar");
if (div_calendar.style.visibility == "hidden")
div_calendar.style.visibility = "visible";

}

</script>

Please help!!!


Viewing all articles
Browse latest Browse all 23244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>