How to set focus on the asp.net textbox in AxPopup form?

To set the focus include this method in your page that is opened in the popup window and call the method without control name in the page load event.

For example to set the focus on txtCustAccount

 

protected void Page_Load(object sender, EventArgs e)

    {

       

        SetFocus(txtCustAccount);

    }

public static void SetFocus(Control control)

    {

        StringBuilder sb = new StringBuilder();

        sb.Append("<script language='JavaScript'>");

        sb.Append("function SetFocus(){document.");

        Control p = control.Parent;

        while (!(p is System.Web.UI.HtmlControls.HtmlForm)) p = p.Parent;

        sb.Append(p.ClientID);

        sb.Append("['");

        sb.Append(control.UniqueID);

        sb.Append("'].focus();}");

       

        sb.Append("window.onload = SetFocus;</script>\r\n");

        control.Page.RegisterClientScriptBlock("SetFocus", sb.ToString());

    }