manishsawant
MIS
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
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