PC Review


Reply
Thread Tools Rate Thread

Changing a Server Control's Property when it loses focus

 
 
jjwhite01@gmail.com
Guest
Posts: n/a
 
      30th Jan 2007
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?

 
Reply With Quote
 
 
 
 
=?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=
Guest
Posts: n/a
 
      30th Jan 2007
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


"(E-Mail Removed)" 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?
>
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to detect when Tab Control loses its focus =?Utf-8?B?RWl0YW4=?= Microsoft C# .NET 11 15th Aug 2007 09:20 PM
Mouse click in form control loses focus after one blink =?Utf-8?B?U3VuS2luZw==?= Windows XP General 3 3rd May 2007 05:34 AM
Detecting when a datagrid control loses focus Greg Microsoft C# .NET 3 18th Apr 2006 05:23 PM
Winform with HelpProvider control loses focus. oscarmorasu Microsoft Dot NET Framework Forms 0 31st Mar 2006 10:12 PM
How to tell when control loses focus JezB Microsoft Dot NET Framework Forms 4 31st Oct 2005 06:37 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:18 AM.