Solved

How to unfocus

Posted on 2004-04-04
4
332 Views
Last Modified: 2008-02-01
Is it possible to unfocus so that none of interactive controls are focused? Maybe focus on page or label?

Thanks.
0
Comment
Question by:gromul
4 Comments
 
LVL 28

Assisted Solution

by:mmarinov
mmarinov earned 100 total points
ID: 10755313
you can use javascript and blur() method of the control
From MSDN:
blur Method

--------------------------------------------------------------------------------

Causes the element to lose focus and fires the onblur event.

HTH
B..G
0
 
LVL 29

Assisted Solution

by:David H.H.Lee
David H.H.Lee earned 100 total points
ID: 10756717
gromul,
>>Is it possible to unfocus so that none of interactive controls are focused? Maybe focus on page or label?
-You can set the focus into a hidden object. I think this method is quite simple as you wish to solve your problem.
eg:
<input type="hidden" name="focusItem" id="focusItem"/>
0
 
LVL 7

Accepted Solution

by:
dante469 earned 300 total points
ID: 10758423
gromul,

Can't set focus to an ASP:Label because it renders as a <Span> and that is not able to accept focus.  Also the address bar and menu bars are not java accessible due to brower security :(...  Looked for a generic solution using built in components, but no great solution...

Either could convert one of your labels to a read/only text box...  Advantage can set focus, disadvantage will become part of the tab sequence...

x_com idea of creating an html: hidden control seems to be on the right track...  Please remember this needs to be an html:control b/c if you take and ASP: control and set visibility=False then the control is never rendered to the browser.

Codebehind to set focus:
Sub setfocus(ByVal ctrl As String)
        'Please remember JavaScript objects are case sensitive
        Dim sJava As String = "<script language='Javascript'>document.Form1." & ctrl & ".focus(); </script>"
        RegisterStartupScript("setfocus", sJava)
End Sub

Call this from your event:
setfocus("hiddenfocus")

hidden control in .aspx page:
<input type="hidden" name="hiddenfocus" />

Have Fun,
Dante
0
 

Author Comment

by:gromul
ID: 10762110
Thanks guys.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now