Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Textbox focus on button click

Status
Not open for further replies.
Apr 11, 2002
193
IN
Hi,

I am using ASP.net 2.0. I want to give focus on a textbox on a click of a button. I have written a javascript function and i am adding it as a attribute to the button.
Javascript :
function GetFocusonElements(element)
{
window.parent.frames('MainFrame').document.getElementById(element).focus();
return false;
}

Code Behind :
btn.Attributes.Add("onClick", "javascript:return GetFocusonElements('txtQty');");

When i click on the button the javascript function gets executed but there is no focus and there is a postback. When i click the second time then there is no postback and the textbox gets the focus.

I cant use focus() of textbox as i am using AJAX.

Can anyone please help me with this issue.

Thank you,
Manish
 
Hi Mark,

I am adding the "btn.Attributes.Add" line in page_load event.

Thanks,
Manish
 
Mark,

It still give the same result. I am confused.

You want to have a look at the entire html content?

Thanks,
Manish
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top