Solved

C#

Posted on 2004-03-25
6
187 Views
Last Modified: 2010-04-06
What is the C# or ASP equivilant of the javascript.Focus command?
Thanks in advance.
_oTtAw-
0
Comment
Question by:_oTtAw-
6 Comments
 
LVL 17

Accepted Solution

by:
dorward earned 50 total points
ID: 10682374
Any such command would depend on your graphical toolkit library.

Assuming you are talking about server side C# and ASP - there is no such equivilant.

The server side code doesn't present a user interface, it outputs (usually) HTML (often with CSS and/or JavaScript).

The outputted JavaScript could call element.focus() onload. e.g.

... %>

<script type="text/javascript">
window.onload = function () { document.getElementById('id-of-element').focus(); }
</script>

<% ...
0
 

Assisted Solution

by:Sharbel99
Sharbel99 earned 50 total points
ID: 10683603
The closest you will come to it would be to use the RegisterStartupScript in your Page_Load  to set focus to the control you want.  However, you could just as easily do it in the HTML itself.  You have to understand that ASP and ASP.NET are server technologies, and thus all your programming is executed on the server.

So if you need to do it programmatically in your Server script, use the RegisterStartupScript to set focus to the control you want, other than that, use Javascript as its a client side function.
0
 

Expert Comment

by:leebee300
ID: 10685571
you cant do it
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
RSS Feed Validation 2 59
Select distinct 25 83
JQuery tracking event. 3 57
cookies analysis tools 2 72
There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

867 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

12 Experts available now in Live!

Get 1:1 Help Now