0

I have a website that is working well, except for one problem. I have a text field which takes in ID value of the member and populates the details of the member.

When I try to fetch details of a user, the Cursor should automatically show up in the textbox, whether the results were found or not. This works perfectly on the localhost project but doesnt work on the Production.

Using ASP.NET and C# for this.

Control textControl = FindControl("txtIDValue");
            if (textControl != null)
            {

                ScriptManager.GetCurrent(this.Page).SetFocus(textControl);
            }

The above is the code I use. Can someone please help me? I have been struggling with this past 2 days!

4

1 回答 1

0

试试这个:

TextBox textControl = (TextBox)this.FindControl("txtIDValue");
if (textControl != null)
{
    textControl.Focus();
}

这样您就不会使用ScriptManager并将控件转换为TextBox.

于 2013-08-28T17:48:35.723 回答