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!

Anan
  • 103
  • 2
  • 13

1 Answers1

0

Try this instead:

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

This way you don't use the ScriptManager and cast the control to a TextBox.

Hanlet Escaño
  • 17,114
  • 8
  • 52
  • 75
  • Check the console, make sure you do not have any exceptions there. If there is any exception, let me know what it is. – Hanlet Escaño Aug 28 '13 at 17:54
  • I find this error: Error 215 It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS. – Anan Aug 28 '13 at 18:04
  • Does the page run at all? Or do you just get that error in the Asp.net error page ? (the yellow page), or do you get that error in the browser's console? – Hanlet Escaño Aug 28 '13 at 18:05
  • I get the error on the console for my Localhost, but it runs fine on the production. Page works – Anan Aug 28 '13 at 18:19
  • So the page works and you still get that error. That is very strange. Try re-setting your Virtual Directory for this project. There is no reason for this error. – Hanlet Escaño Aug 28 '13 at 18:23