By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,208 Members | 1,550 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,208 IT Pros & Developers. It's quick & easy.

What happens between events Load and PreRender. ASP.NET bug?

P: n/a
Hi,

First of all sorry for the long post but I believe it is quite an
interesting as well as advanced and complex problem.

I have a problem with the checkbox control I have in my repeater.
I am using a repeater that I bind to some data in the Page_Load method.
That page is heavy and highly dynamic and the viewstate of the repeater and
all the controls existing in that repeater are set to "False" as none of the
information in the repeater needs to be posted back to the server. It is
rather an other control in that page that makes the postback happen and
repopulate the repeater upon those values. Those controls actually filter
date in and out. The repeater can be seen as a read only view of data.

To visualize the problem let have a simplified view of the repeater and for
later purpose, I will also put in brackets the UniqueID of each checkbox
control in my repeater. My repeater got 3 rows, each row got a checkbox.

row number -- checkbox
1 true
(Repeater:_ctl1:CheckBoxSuspended)
2 false
(Repeater:_ctl2:CheckBoxSuspended)
3 false
(Repeater:_ctl3:CheckBoxSuspended)

When i select some options in my page that makes the page postback, the
Page_Load run, and due to the option i chose, only the row number 3 will be
selected from my dataset and then only that row will be binded to my
repeater.
In the Repeater_ItemDataBound event handler, I read the checkbox value from
the database (which is false) and assign in to the checkbox. So far, so
good. But the HTML rendered displays the checkbox being true.

To visualize the problem, My repeater displays:

rowNumber -- checkbox
3 true
(Repeater:_ctl1:CheckBoxSuspended)

instead of:

rowNumber -- checkbox
3 false
(Repeater:_ctl1:CheckBoxSuspended)

Wondering why, I overloaded a few event handlers in my page and I see that
AFTER Page.OnLoad() method is called and BEFORE Page.OnPreRender() is
called, the checkbox value is changed from false (the value i manually set
when i databind the repeater) to true, thus making the CheckedChanged event
to fire.
My only clue is that in between Page.OnLoad() and Page.OnPreRender() , the
ASP.NET runtime retrieves what ASP.NET think is the past value of the
checkbox (as it takes the old value of the control with the uniqueID
Repeater:_ctl1:CheckBoxSuspended and put it in the new control with that
same UniqueID). The problem is that even those controls have the same
UniqueID, they correspond to different data in the DB and then, must keep
their value I set at databinding time.
Then I wonder if there is a bug in the ASP.NET lifecyle or if it is me who
is not aware of some features. But i think it is very strange that ASP.NET
decide by "itself" to set the value of my checkbox control AFTER I set it by
myself in the binding of my repeater. This is in my opinion something that
should never happen.
Also where does ASP.NET can possibly know what was the previous value of
Repeater:_ctl1:CheckBoxSuspended as i set EnableViewState="False" in the
aspx code? Is it from some cache? or is the viewstate saved anyway?

Any guru in here who can give me an help and explain me how to solve this?
If needed i could send over all my source code but as it is part of an
application that would mean a lot of code!

Best regards and thanks to have read this until the end !

Francois
Nov 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Just post the code where the checked state of the checkbox is set
(databinding?)
(probably in page load)

cheers,
mortb
"Francois" <fr******@bettinghouses.com_NOSPAM> wrote in message
news:Oh**************@TK2MSFTNGP15.phx.gbl...
Hi,

First of all sorry for the long post but I believe it is quite an
interesting as well as advanced and complex problem.

I have a problem with the checkbox control I have in my repeater.
I am using a repeater that I bind to some data in the Page_Load method.
That page is heavy and highly dynamic and the viewstate of the repeater
and
all the controls existing in that repeater are set to "False" as none of
the
information in the repeater needs to be posted back to the server. It is
rather an other control in that page that makes the postback happen and
repopulate the repeater upon those values. Those controls actually filter
date in and out. The repeater can be seen as a read only view of data.

To visualize the problem let have a simplified view of the repeater and
for
later purpose, I will also put in brackets the UniqueID of each checkbox
control in my repeater. My repeater got 3 rows, each row got a checkbox.

row number -- checkbox
1 true
(Repeater:_ctl1:CheckBoxSuspended)
2 false
(Repeater:_ctl2:CheckBoxSuspended)
3 false
(Repeater:_ctl3:CheckBoxSuspended)

When i select some options in my page that makes the page postback, the
Page_Load run, and due to the option i chose, only the row number 3 will
be
selected from my dataset and then only that row will be binded to my
repeater.
In the Repeater_ItemDataBound event handler, I read the checkbox value
from
the database (which is false) and assign in to the checkbox. So far, so
good. But the HTML rendered displays the checkbox being true.

To visualize the problem, My repeater displays:

rowNumber -- checkbox
3 true
(Repeater:_ctl1:CheckBoxSuspended)

instead of:

rowNumber -- checkbox
3 false
(Repeater:_ctl1:CheckBoxSuspended)

Wondering why, I overloaded a few event handlers in my page and I see that
AFTER Page.OnLoad() method is called and BEFORE Page.OnPreRender() is
called, the checkbox value is changed from false (the value i manually set
when i databind the repeater) to true, thus making the CheckedChanged
event
to fire.
My only clue is that in between Page.OnLoad() and Page.OnPreRender() , the
ASP.NET runtime retrieves what ASP.NET think is the past value of the
checkbox (as it takes the old value of the control with the uniqueID
Repeater:_ctl1:CheckBoxSuspended and put it in the new control with that
same UniqueID). The problem is that even those controls have the same
UniqueID, they correspond to different data in the DB and then, must keep
their value I set at databinding time.
Then I wonder if there is a bug in the ASP.NET lifecyle or if it is me who
is not aware of some features. But i think it is very strange that ASP.NET
decide by "itself" to set the value of my checkbox control AFTER I set it
by
myself in the binding of my repeater. This is in my opinion something that
should never happen.
Also where does ASP.NET can possibly know what was the previous value of
Repeater:_ctl1:CheckBoxSuspended as i set EnableViewState="False" in the
aspx code? Is it from some cache? or is the viewstate saved anyway?

Any guru in here who can give me an help and explain me how to solve this?
If needed i could send over all my source code but as it is part of an
application that would mean a lot of code!

Best regards and thanks to have read this until the end !

Francois

Nov 18 '05 #2

P: n/a
in the databinding, the binding code is:

CheckBoxValue checkBoxSuspended = (CheckBoxValue)
repeaterItem.FindControl("CheckBoxSuspended");
checkBoxSuspended.Checked = (bool) record["isSuspended"];
checkBoxSuspended.Attributes.Add("onclick", "changeSuspendGame(" +
checkBoxSuspended.ClientID + ", " + gameId + ")");

But this code works well as when i run it in debug mode everything is fine,
as i said in the original post it is later that some internal code of the
asp.net runtime changes the values by itself.

Francois
"mortb" <mortb1<noospam<@hotmail.com> wrote in message
news:ew**************@TK2MSFTNGP10.phx.gbl...
Just post the code where the checked state of the checkbox is set
(databinding?)
(probably in page load)

cheers,
mortb
"Francois" <fr******@bettinghouses.com_NOSPAM> wrote in message
news:Oh**************@TK2MSFTNGP15.phx.gbl...
Hi,

First of all sorry for the long post but I believe it is quite an
interesting as well as advanced and complex problem.

I have a problem with the checkbox control I have in my repeater.
I am using a repeater that I bind to some data in the Page_Load method.
That page is heavy and highly dynamic and the viewstate of the repeater
and
all the controls existing in that repeater are set to "False" as none of
the
information in the repeater needs to be posted back to the server. It is
rather an other control in that page that makes the postback happen and
repopulate the repeater upon those values. Those controls actually filter date in and out. The repeater can be seen as a read only view of data.

To visualize the problem let have a simplified view of the repeater and
for
later purpose, I will also put in brackets the UniqueID of each checkbox
control in my repeater. My repeater got 3 rows, each row got a checkbox.

row number -- checkbox
1 true
(Repeater:_ctl1:CheckBoxSuspended)
2 false
(Repeater:_ctl2:CheckBoxSuspended)
3 false
(Repeater:_ctl3:CheckBoxSuspended)

When i select some options in my page that makes the page postback, the
Page_Load run, and due to the option i chose, only the row number 3 will
be
selected from my dataset and then only that row will be binded to my
repeater.
In the Repeater_ItemDataBound event handler, I read the checkbox value
from
the database (which is false) and assign in to the checkbox. So far, so
good. But the HTML rendered displays the checkbox being true.

To visualize the problem, My repeater displays:

rowNumber -- checkbox
3 true
(Repeater:_ctl1:CheckBoxSuspended)

instead of:

rowNumber -- checkbox
3 false
(Repeater:_ctl1:CheckBoxSuspended)

Wondering why, I overloaded a few event handlers in my page and I see that AFTER Page.OnLoad() method is called and BEFORE Page.OnPreRender() is
called, the checkbox value is changed from false (the value i manually set when i databind the repeater) to true, thus making the CheckedChanged
event
to fire.
My only clue is that in between Page.OnLoad() and Page.OnPreRender() , the ASP.NET runtime retrieves what ASP.NET think is the past value of the
checkbox (as it takes the old value of the control with the uniqueID
Repeater:_ctl1:CheckBoxSuspended and put it in the new control with that
same UniqueID). The problem is that even those controls have the same
UniqueID, they correspond to different data in the DB and then, must keep their value I set at databinding time.
Then I wonder if there is a bug in the ASP.NET lifecyle or if it is me who is not aware of some features. But i think it is very strange that ASP.NET decide by "itself" to set the value of my checkbox control AFTER I set it by
myself in the binding of my repeater. This is in my opinion something that should never happen.
Also where does ASP.NET can possibly know what was the previous value of
Repeater:_ctl1:CheckBoxSuspended as i set EnableViewState="False" in the
aspx code? Is it from some cache? or is the viewstate saved anyway?

Any guru in here who can give me an help and explain me how to solve this? If needed i could send over all my source code but as it is part of an
application that would mean a lot of code!

Best regards and thanks to have read this until the end !

Francois


Nov 18 '05 #3

P: n/a
after a control is created, the ipostbackdatahandler is called if any
postback data is found for it. control which will receive postback data
must be created by prerender.

if you data is readonly, rather than use a checkboxs and textboxes, which
have to postback, use images and literals. you could also create a new
checkbox control which ignored the postback data.
-- bruce (sqlwork.com)

"Francois" <fr******@bettinghouses.com_NOSPAM> wrote in message
news:Oh**************@TK2MSFTNGP15.phx.gbl...
| Hi,
|
| First of all sorry for the long post but I believe it is quite an
| interesting as well as advanced and complex problem.
|
| I have a problem with the checkbox control I have in my repeater.
| I am using a repeater that I bind to some data in the Page_Load method.
| That page is heavy and highly dynamic and the viewstate of the repeater
and
| all the controls existing in that repeater are set to "False" as none of
the
| information in the repeater needs to be posted back to the server. It is
| rather an other control in that page that makes the postback happen and
| repopulate the repeater upon those values. Those controls actually filter
| date in and out. The repeater can be seen as a read only view of data.
|
| To visualize the problem let have a simplified view of the repeater and
for
| later purpose, I will also put in brackets the UniqueID of each checkbox
| control in my repeater. My repeater got 3 rows, each row got a checkbox.
|
| row number -- checkbox
| 1 true
| (Repeater:_ctl1:CheckBoxSuspended)
| 2 false
| (Repeater:_ctl2:CheckBoxSuspended)
| 3 false
| (Repeater:_ctl3:CheckBoxSuspended)
|
| When i select some options in my page that makes the page postback, the
| Page_Load run, and due to the option i chose, only the row number 3 will
be
| selected from my dataset and then only that row will be binded to my
| repeater.
| In the Repeater_ItemDataBound event handler, I read the checkbox value
from
| the database (which is false) and assign in to the checkbox. So far, so
| good. But the HTML rendered displays the checkbox being true.
|
| To visualize the problem, My repeater displays:
|
| rowNumber -- checkbox
| 3 true
| (Repeater:_ctl1:CheckBoxSuspended)
|
| instead of:
|
| rowNumber -- checkbox
| 3 false
| (Repeater:_ctl1:CheckBoxSuspended)
|
| Wondering why, I overloaded a few event handlers in my page and I see that
| AFTER Page.OnLoad() method is called and BEFORE Page.OnPreRender() is
| called, the checkbox value is changed from false (the value i manually set
| when i databind the repeater) to true, thus making the CheckedChanged
event
| to fire.
| My only clue is that in between Page.OnLoad() and Page.OnPreRender() , the
| ASP.NET runtime retrieves what ASP.NET think is the past value of the
| checkbox (as it takes the old value of the control with the uniqueID
| Repeater:_ctl1:CheckBoxSuspended and put it in the new control with that
| same UniqueID). The problem is that even those controls have the same
| UniqueID, they correspond to different data in the DB and then, must keep
| their value I set at databinding time.
| Then I wonder if there is a bug in the ASP.NET lifecyle or if it is me who
| is not aware of some features. But i think it is very strange that ASP.NET
| decide by "itself" to set the value of my checkbox control AFTER I set it
by
| myself in the binding of my repeater. This is in my opinion something that
| should never happen.
| Also where does ASP.NET can possibly know what was the previous value of
| Repeater:_ctl1:CheckBoxSuspended as i set EnableViewState="False" in the
| aspx code? Is it from some cache? or is the viewstate saved anyway?
|
| Any guru in here who can give me an help and explain me how to solve this?
| If needed i could send over all my source code but as it is part of an
| application that would mean a lot of code!
|
| Best regards and thanks to have read this until the end !
|
| Francois
|
|
Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.