This is a migrated thread and some comments may be shown as answers.

[Solved] set focus on asp:TextBox

1 Answer 134 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 28 Aug 2009, 08:40 AM
Hi, 

I have a grid call RadGridArea, in the PreRender event, I need to set the grid into edit mode in the
page load.  But I want to set the focus to an aspTextBox control.

How can I do? please help.

    protected void RadGridArea_PreRender(object sender, EventArgs e)
    {
        PropertyArea projarea = new PropertyArea();
        DataTable dt = projarea.GetPropertyAreaByPropertyId(this.property_id);

        if (dt.Rows.Count == 0)
        {
            for (int i = 0; i < this.RadGridArea.Items.Count; i++)
            {
                this.RadGridArea.MasterTableView.Items[i].Edit = true;
            }
            this.RadGridArea.Rebind();
        }

        if (!Page.IsPostBack)
        {
            string s = "<script type='text/javascript'>document.getElementById('" + this.txtPropertyName.ClientID + "').focus();</script>";
            ClientScript.RegisterStartupScript(Page.GetType(), Guid.NewGuid().ToString(), s, false);
        }
    }

The above coding is not work.

Regards,

Paul

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 28 Aug 2009, 11:46 AM
Hi,

I have tried your code with a text box outside the grid(if that is your scenario) and it is working fine on my side.I was able to focus on the text box.If that is not you requirement, then you can check out  help document that explains how to set focus on the textbox in the edit form .
http://www.telerik.com/help/aspnet/grid/grdsetfocusontextboxesineditcontrol.html.

Thanks,
Shinu


Tags
Grid
Asked by
Paul
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or