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

Focussing RadTextBox on PageLoad

1 Answer 51 Views
Input
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 17 Sep 2010, 06:17 AM
Hi,

We have a page with a RadTextBox:

<telerik:RadTextBox ID='txtSearch' runat='server' Skin='Office2007'></telerik:RadTextBox>

a RadTreeView:
<telerik:RadTreeView ID='rtvCategories' runat='server' ShowLineImages="false"
                Skin="Outlook" DataFieldID="ID" OnClientNodeClicking="NodeClicking" OnClientMouseOver="NodeHover"
                DataFieldParentID="ParentID" DataTextField="Name" DataValueField="ID">
                <CollapseAnimation Type="None" />
                <ExpandAnimation Type="None" />
</telerik:RadTreeView>

and a RadToolTipManager:

<telerik:RadToolTipManager ID='rttmManager' runat='server'
            Skin="Office2007" Width='250px' Sticky="true" ShowDelay="1000" OnAjaxUpdate="rttmManager_AjaxUpdate">
</telerik:RadToolTipManager>


Basically, when you hover over a leaf node in the tree, a javascript method creates a new tooltip for the node and call the "show" method for that tooltip. The tooltip manager's "rttmManager_AjaxUpdate" function is called in the CodeBehind, making a database call to populate the tooltip with the proper content:

e.UpdatePanel.ContentTemplateContainer.Controls.Add(new LiteralControl(content));

We have a problem in that whenever the ToolTips load, the RadTextBox (txtSearch) gains focus and the page scrolls up to it. So you could be viewing the tree all the way at the bottom, scrolled down quite far; if you hover over a node and the tooltip loads it will scroll you back to the top of the page. Here is our Page_Load method:

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                /*Snip some business logic*/

                if (!String.IsNullOrEmpty(Request.QueryString["search"]))
                {
                    txtSearch.Text = Request.QueryString["search"];
                    RadScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "_categoriesSearchOnLoad_", "Search();", true);
                }

                txtSearch.Focus();
            }
        }

Can you think of any reason why we would be experiencing this behaviour?

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 22 Sep 2010, 12:03 PM
Hello Peter,

The JS code registered with RegisterClientScriptBlock should be executed only on initial page load. Here is a similar demo to your scenario, which works as expected, if I modify it to resemble your scenario:

http://demos.telerik.com/aspnet-ajax/tooltip/examples/targetcontrolsandajax/defaultcs.aspx?product=grid

Best wishes,
Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Input
Asked by
Peter
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or