A problem with the inline page code in ASP.NET
- 2020-05-09 18:22:53
- OfStack
Such as
The parent page:
Child pages:
When writing the check-in code in *.aspx, only this.HotelID will be read, even if the property value read using base.HotelID is still this.HotelID
For example, in UpdateAlbumAttachments.aspx < %=base.HotelID % > You get a 0 instead of a 1
Of course, you can get base.HotelID in the background code
It can only be distinguished by different names. I don't know why, is it ASP. bug of NET?
((BasePage) this).HotelID can get 1
The parent page:
public class BasePage : System.Web.UI.Page
{
public int HotelID
{
get
{
return 1;
}
}
}
Child pages:
public partial class UpdateAlbumAttachments : BasePage
{
public new int HotelID
{
get
{
return 0;
}
}
}
When writing the check-in code in *.aspx, only this.HotelID will be read, even if the property value read using base.HotelID is still this.HotelID
For example, in UpdateAlbumAttachments.aspx < %=base.HotelID % > You get a 0 instead of a 1
Of course, you can get base.HotelID in the background code
It can only be distinguished by different names. I don't know why, is it ASP. bug of NET?
((BasePage) this).HotelID can get 1