4

I had this line in my page:

<asp:TextBox runat="server" ID="Server" />

And I was getting the following error:

Compiler Error Message: CS1061: 'System.Web.UI.WebControls.TextBox' does not contain a definition for 'ScriptTimeout' and no extension method 'ScriptTimeout' accepting a first argument of type 'System.Web.UI.WebControls.TextBox' could be found (are you missing a using directive or an assembly reference?)

Source Error:

Line 172:                global::ASP.applications_returndata_releasemanagement_aspx.@__initialized = true;
Line 173:            }
Line 174:            this.Server.ScriptTimeout = 30000000;
Line 175:        }
Line 176:

After changing the ID to something else it was fine.

Does anyone know why you can't use "Server" as control ID? I searched and I couldn't find anything about reserved words for asp.net controls.

4

2 回答 2

5

Server is one of a number of predefined properties in the base class of any ASP.Net page - this list also includes Response, Request, etc.

By calling your own control Server, you are overriding the default properties and rendering meaningless certain .Net calls including, in this case, Server.ScriptTimeout.

于 2013-08-28T08:44:08.840 回答
5

That's because System.Web.UI.Page has already a field called Server (You can see it when you navigate to the class definition of System.Web.UI.Page).

于 2013-08-28T08:44:22.390 回答