I have couple of textboxes inside of WebTan v10.1 control and I cannot seem to put focus on the first textbox during the page load event. Before this I was using WebUltraTab v9.2 and I had no problem. Has anyone seen this and knows a way to make this work.
Hi,
The WebTab readjusts its bounds, child html elements and content on the client. To avoid jumping on load/reload, the visibility of control is hidden. That means if external codes, like TextBox1.Focus(), attempt to set focus to a child element on initialization of page, then that fails because at that time child is invisible.
The UltraWebTab does not do similar adjustments on client, so, its content is visible on initialization.
Therefore, you need to set focus for the WebTab on the client. This can be done in server side Page_Load event by registering a client script block and using a delay.
For example to set focus to TextBox1:
string id = this.TextBox1.ClientID; string js = "window.setTimeout(\"try { document.getElementById('" + id + "').focus(); } catch(e){}\", 1000);"; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "TabFocusKey", js, true);
Thanks,Valerie
Were you able to set focus to the textbox as you desired?
Please let me know if you have any other questions.
Thanks,
Valerie