HasanG
HasanG

Reputation: 13161

Using Page keyword in asp.net

Is it necessary to use the Page keyword in asp.net? For example, are there differences setting the Title or control if the page IsPostBack?

If we don't use the Page keyword will there be a problem in the future?

Because the code appears to do the same thing:

Page.Title = "Test";

is equal to

Title = "Test";

Upvotes: 0

Views: 355

Answers (1)

FishBasketGordo
FishBasketGordo

Reputation: 23142

ASP.NET pages and controls ultimately inherit from Control, which has a property named Page, which refers to the current page the control is on, or, in the case of pages, the page themselves. As far as I know, there's no difference between calling Page.Title and Title from your pages, because they both refer to the same object. The question then, becomes a matter of preference and convention. I would pick one way and stick with it for readability.

Reference:

Upvotes: 2

Related Questions