locked
"A Runtime Error has occurred." on WebForm_AutoFocus RRS feed

  • Question

  • User-1041323598 posted

    I have a page with a Label and a TextBox and I want to set focus on the TextBox.

    The problem is that I get an alert telling me "A Runtime Error has occurred." and asking if I want to debug Line: 52 for the Error: Object Expected.  When I click Yes, I'm taken to a line containing: "WebForm_AutoFocus('txt');"

    This is happening on Server 2003.  I don't have any trouble running it locally.

    Does anyone know how to fix this?

    The page and codebehind follow:

    1    <%@ Page Language="C#" AutoEventWireup="true" Codebehind="Default.aspx.cs" Inherits="ecmaScriptVersion._Default" %>
    2   
    3    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    4    <html xmlns="http://www.w3.org/1999/xhtml">
    5    <head runat="server">
    6       <title>Untitled Page</title>
    7    </head>
    8    <body>
    9       <form id="form1" runat="server">
    10         <div>
    11            version number of ECMAScript:
    12            <asp:Label ID="Label1" runat="server" Text="Label" Width="120px">
    13            </asp:Label>
    14            <br />
    15            <br />
    16            <asp:TextBox ID="txt" runat="server">
    17            </asp:TextBox> <br />
    18         </div>
    19      </form>
    20   </body>
    21   </html>
    22   

     

     

    1    using System;
    2    using System.Web; // HttpBrowserCapabilities
    3    
    4    namespace ecmaScriptVersion
    5    {
    6       public partial class _Default:System.Web.UI.Page
    7       {
    8          protected void Page_Load( object sender, EventArgs e )
    9          {
    10            HttpBrowserCapabilities browserCapabilities = Request.Browser;
    11   
    12   
    13            Label1.Text = browserCapabilities.EcmaScriptVersion.ToString();
    14            txt.Focus();
    15         }
    16      }
    17   }
    18   
    
      
    Monday, October 1, 2007 1:04 PM

Answers

  • User-2115483147 posted

    I have a page with a Label and a TextBox and I want to set focus on the TextBox.
     

    Hi ashwinanimal,

    Base on my understanding, you can try to use JavaScript to solve your problem, see the following code snippet:

    <script language=javascript>

    function cmdButton1_Clicked()

    {

    document.all('txtInput1').focus(); return false;

    }

    function cmdButton2_Clicked()

    {

    document.all('txtInput2').focus(); return false;

    }

    </script>
     

    To know more, please checkout this article,

     

    Please correct me if I have misunderstood your mean, please LET ME KNOW, Thanks, 

    Hope it helps,

    Hong Gang

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, October 7, 2007 7:55 AM
  • User-1041323598 posted

     

    It turned out to be an issue with SiteMinder.  I had to uncheck "Verify that file exists" for the "Wildcard application map" for SiteMinder (Website Properties->Home Directory tab->Configuration).  Once I made the change, my browser started receiving webResource.axd.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, October 12, 2007 4:42 PM

All replies

  • User998605613 posted

    Hi,

    Instead of txt.Focus(); try this:

    Page.RegisterStartupScript("SetFocus", "<script>document.getElementById('" & txt.ClientID & "').focus();</script>") 

    Hope this helps. 

    Monday, October 1, 2007 1:47 PM
  • User-1041323598 posted

    Hi Raja,

    Thank you for replying.

    I understand your code will allow the page to run, but I need to understand why this framework supplied JavaScript function is not available.

    Ashwin

    Monday, October 1, 2007 2:11 PM
  • User-1041323598 posted

    After searching the Web for similar problems, it looks like this may be an issue with webResource.axd not making it to the client.

    Some of the posts I've come across recommend disabling compresson of webResource.axd.

    Can anyone describe how to do this (disable compression of webResource.axd)?

    Tuesday, October 2, 2007 10:32 AM
  • User-2115483147 posted

    I have a page with a Label and a TextBox and I want to set focus on the TextBox.
     

    Hi ashwinanimal,

    Base on my understanding, you can try to use JavaScript to solve your problem, see the following code snippet:

    <script language=javascript>

    function cmdButton1_Clicked()

    {

    document.all('txtInput1').focus(); return false;

    }

    function cmdButton2_Clicked()

    {

    document.all('txtInput2').focus(); return false;

    }

    </script>
     

    To know more, please checkout this article,

     

    Please correct me if I have misunderstood your mean, please LET ME KNOW, Thanks, 

    Hope it helps,

    Hong Gang

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, October 7, 2007 7:55 AM
  • User-1041323598 posted

     

    Thank you for replying, Hong

     

    I understand the code you suggest will get the page to work, but I really need WebForm_AutoFocus and all the other routines contained in webResource.axd to work (that is, be available to the Web browser).

     

    From the feedback I'm getting, it appears that the behavior I'm encountering is caused by webResource.axd being compressed.  I'm in the process of verifying this on my site.

     

    Ashwin

    Monday, October 8, 2007 12:53 PM
  • User1414969843 posted

     Thank for your reply Hong

    -----------------------------------------------------------------------------------------------
    .NET Components Blog

    Monday, October 8, 2007 1:59 PM
  • User-544240524 posted

    Could this be because the virtual directory you are running under is set to run as asp.net 1.1 instead of 2.0?

    Monday, October 8, 2007 10:24 PM
  • User-1041323598 posted

    I just verified that the virtual directory is set to ASP.NET version: 2.0.50727.

    Wednesday, October 10, 2007 10:51 AM
  • User-1041323598 posted

     

    It turned out to be an issue with SiteMinder.  I had to uncheck "Verify that file exists" for the "Wildcard application map" for SiteMinder (Website Properties->Home Directory tab->Configuration).  Once I made the change, my browser started receiving webResource.axd.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, October 12, 2007 4:42 PM