Solved

How to unfocus

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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
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…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

707 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