Solved

How to unfocus

Posted on 2004-04-04
4
334 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
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 …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

815 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

9 Experts available now in Live!

Get 1:1 Help Now