These forums are currently read-only due to receiving more spam than actual discussion. Sorry.

It is currently Sat Dec 02, 2017 4:12 pm Advanced search

ASP Textbox Focus and Select Script using C#

If you are stuck or have questions regarding HTML or other Web technologies, ask your questions here. No question too dumb!

ASP Textbox Focus and Select Script using C#

Postby jomarporras » Wed Feb 08, 2012 11:06 am

Hi...My problem is.How to focus on my textbox control after postback so that the cursor will point into lastindex of my textbox..Thank you
jomarporras
<h6>
 
Posts: 1
Joined: Tue Feb 07, 2012 1:04 pm

Re: ASP Textbox Focus and Select Script using C#

Postby JAB Creations » Sat Feb 11, 2012 7:08 pm

ASP and C# aren't used for client programming, they can only output client code.

You would use focus() method to give focus to an element such as a text input element.

XHTML
Code: Select all
<input id="item4" name="item4" type="text" value="" />


JavaScript
Code: Select all
document.getElementById('item4').focus();
User avatar
JAB Creations
<aside>
 
Posts: 566
Joined: Tue Mar 13, 2007 4:48 am
Location: Sarasota Florida, USA

Re: ASP Textbox Focus and Select Script using C#

Postby zcorpan » Tue Feb 14, 2012 9:09 am

Or better (if you want to focus on page load), use the autofocus="" attribute.
zcorpan
<article>
 
Posts: 807
Joined: Tue Feb 06, 2007 8:29 pm
Location: Sweden


Return to Help & Advice

Who is online

Users browsing this forum: No registered users and 1 guest