By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,728 Members | 2,488 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,728 IT Pros & Developers. It's quick & easy.

focus Controls

P: 1
Hi All,

I have a web based application and i want to have focus on a text box on click of a button i have been trying the below solution but unfortunately its working in my test application but not in my orignal application. please let me know any solution other than this.

Expand|Select|Wrap|Line Numbers
  1. private void SetFocus(String ctrlID)
  2. {
  3. // Build the JavaScript String
  4. System.Text.StringBuilder sb = new System.Text.StringBuilder();
  5. sb.Append("<script language='javascript'>");
  6. sb.Append("document.getElementById('");
  7. sb.Append(ctrlID);
  8. sb.Append("').focus()");
  9. sb.Append("</script>");
  11. // Register the script code with the page.
  12. Page.RegisterStartupScript("FocusScript", sb.ToString());
  13. }
and calling this function when needed...
Please help me out.....
Jul 12 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.