Answered by:
IsPostBack

Question
-
User1374904634 posted
Hi,
I've tried the first walkthrough and I've noticed that if I write
if not Page.IsPostBack
instead of
if not IsPostBack
then the test always fails. It seems that using Page.IsPostBack always returns true.
Am I missing something?
Sunday, November 5, 2006 5:29 AM
Answers
-
User1641955678 posted
Ah, I see what's going on. When you write 'Page', it gets interpreted as a System.Web.UI.Page type, instead of the Page instance. Hence Page.IsPostBack refers to the property itself, instead of the value of the property. Hence Page.IsPostBack is always true.
But we should fixed this, as it is confusing. I will open a bug.
For now, you can write either 'IsPostBack', or 'page.IsPostBack' (lower case 'p'). We have logic that makes 'page' always point to the page instance.
Thanks for bringing this up,
David- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, November 5, 2006 8:31 PM
All replies
-
User1001868398 posted
The first time IsPostBack should be false, do you see that?Sunday, November 5, 2006 11:31 AM -
User1374904634 posted
Hi,
yes, IsPostBack returns false. But Page.IsPostBack returns true. Or, better:
if not IsPostBack: Label1.Text = "Your name here"
displays the text, whileif not Page.isPostBack: Label1.Text = "Your name here"
doesn't display any text
By the way, in the first walkthrough, setting Label1.Text = "<Your name here>" is not a good idea, since it will be parsed as an element.
Sunday, November 5, 2006 11:53 AM -
User1641955678 posted
Ah, I see what's going on. When you write 'Page', it gets interpreted as a System.Web.UI.Page type, instead of the Page instance. Hence Page.IsPostBack refers to the property itself, instead of the value of the property. Hence Page.IsPostBack is always true.
But we should fixed this, as it is confusing. I will open a bug.
For now, you can write either 'IsPostBack', or 'page.IsPostBack' (lower case 'p'). We have logic that makes 'page' always point to the page instance.
Thanks for bringing this up,
David- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, November 5, 2006 8:31 PM -
User1001868398 posted
David,
Can you post the bug link after you open it? I have never seen this problem with IronPython
Sunday, November 5, 2006 11:19 PM -
User1641955678 posted
Hi Al,
It is not an IronPython issue, but an issue with how we host IronPython in ASP.NET. As a host, you get to override default behavior and resolve tokens as you like. In this case, we're just not doing it quite correctly. I don't think we have a public bug database for the IronPython for ASP.NET add-in, though we probably should.
thanks,
DavidSunday, November 5, 2006 11:38 PM -
User1374904634 posted
Hi,
thank you David!
Monday, November 6, 2006 3:07 AM -
User1001868398 posted
Thanks David for the infoMonday, November 6, 2006 11:26 AM