Solved

C#

Posted on 2004-03-25
6
189 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

830 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