Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't have control with ID "Server"

Tags:

asp.net

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.

like image 814
Silviu Avatar asked Dec 26 '22 21:12

Silviu


1 Answers

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).

like image 62
Gerco Brandwijk Avatar answered Jun 07 '23 13:06

Gerco Brandwijk