Solved

How to unfocus

Posted on 2004-04-04
4
340 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

740 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