Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
165
Cannot get Control ID of textbox inside of WebTab
posted

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.

Parents
No Data
Reply
  • 14517
    Offline posted

    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

Children