Control focus

J

Javier Ros

Hi guys,
How to Focus a TextBox on page load?

I have this function:

public static void FocusControl(Page pagina, WebControl control)
{
StringBuilder sScript = new StringBuilder();
sScript.Append("<SCRIPT language=\"javascript\">");
sScript.Append(control.ID + ".SetFocus();");
sScript.Append("</SCRIPT>");
pagina.RegisterStartupScript("ForceDefaultToScript2", sScript.ToString());
}

and use it on PageLoad:

TWebTools.FocusControl(this, myTextBox);

but I get a JavaScript Error:

"'MyTextBoxID' not defined"

thanks in advance

..Javier Ros Moreno.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,160
Latest member
CollinStri
Top