473,406 Members | 2,273 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Changing a Server Control's Property when it loses focus

I am working on a web form that contains a Calendar control with an
image button that makes the calendar appear and disappear. However, I
would like to set the visible property of the Calendar control to
false when the control loses focus so that when the user moves to the
next field in the form the calendar disappears. Is there anyway to do
this in ASP.NET or ASP.NET w/ Javascript?

Jan 30 '07 #1
1 1880
Howdy,

Use onblur DOM event of the textbox (i'm assuming control which triggers
calendar to be hidden). You can attach it in the code behing like this:

texBoxVariable.Attributes["onblur"] = "ShowCalendar(false)";

or use expando as below:

<table>
<tr>
<td>Date:<asp:textbox ID="date" runat="server"
onblur="ShowCalendar(false)"/></td>
<td><input type="button" value="..." onclick="ShowCalendar(true)"/></td>
</tr>
<tr>
<td></td>
<td>
<asp:Calendar ID="calendar" runat="server"
Style="position:absolute;display:none"/>
</td>
</tr>
</table>
<script language="javascript">
<!--
function ShowCalendar(visible)
{
var calendar = document.getElementById('<%=calendar.ClientID %>');
if (calendar)
calendar.style.display = visible ? 'block' : 'none';
}
//-->
</script>
hope it helps

Milosz
"jj*******@gmail.com" wrote:
I am working on a web form that contains a Calendar control with an
image button that makes the calendar appear and disappear. However, I
would like to set the visible property of the Calendar control to
false when the control loses focus so that when the user moves to the
next field in the form the calendar disappears. Is there anyway to do
this in ASP.NET or ASP.NET w/ Javascript?

Jan 30 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ron Vecchi | last post by:
I am creating a control to mimic the vs.net MainMenu . The control inherits from control. Is it possible to recieve windows messages when the menu loses focus. I am running into problems after...
2
by: vooose | last post by:
Does anyone know the difference between these two? The doc for LostFocus says 'Occurs when the control loses focus.' whereas for Leave it says 'Occurs when the input focus leaves the control'...
17
by: Zvi Danovich | last post by:
Hi, I am a newby in ASP.NET, and till now wrote only simple "classic" WEB-sites. But - the time came, and now I need that: 1. Server will "listen" for some events on its local machine 2....
4
by: Neil Stevens | last post by:
Hi, Merry Christmas to you all. I have a problem with server controls, i am writing a C# ASP.NET web project and i am creating custom server controls for some of the more common element. One...
3
by: Marty McFly | last post by:
Hello, I have a control class that inherits from System.Web.UI.WebControls.Button. When I drag this control from the "My User Controls" tab in the toolbox onto the form, I want it to reflect the...
1
by: Israel | last post by:
The problem: I want to know, definitively when a slider loses focus after a user has started sliding and hasn't released the mouse yet. It appears that this is captured with the WM_ACTIVATEAPP...
4
by: Jon Slaughter | last post by:
Is there any method to temporarily disable focus changing?(I assume only method is tab or mouse?) This problem has been tieing me up for a while and nothing seems to work. The only thing that I...
11
by: =?Utf-8?B?RWl0YW4=?= | last post by:
Hello, I have a WinForm application. The form has one Tab Control and one ToolStrip. I would like to know what would be the best way to detect when the user is "leaving" the Tab Control and...
3
by: nano2k | last post by:
Each form has its ActiveControl property, but no ActiveControlChanged event to signal that the active control has changed (like ParentChanged event). I tried to trick the form by declaring this...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.