Thursday, March 22, 2012

Working with repeaters without Viewstate

Hi,

I am working on an Asp.net 2.0 web application that uses master pages,
according to our application architecture we should not use Viewstate. Is
there a work around to raise the events fired from the child controls of
repeater when viewstate is disabled?

The scenario is as follows
I have a web page with a repeater that has controls on it, The viewstate is
disabled. The repeater is data bound to an arraylist in the page_load
event(in block if !ISPostback), so when the user requests the page for the
first time the repeater is populated. There is a button in the repeater
which is used to add another row. When this button is clicked the event will
not be fired on the server on postback. this is because the repeater itself
is databound in the page load when its not Postback.

This works fine if we enable viestate, does any one know whether there is a
work around for this? any help is highly appreciated

Thank you
VjYou can do it with a bit of client-side programming. Handle client-side
onclick event for the buttons to make a javascript call myForm.submit().

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
"Vijay" <technical@.peoplewareindia.comwrote in message
news:609819E9-0ACB-48BE-B6F2-DD77C8E43D28@.microsoft.com...

Quote:

Originally Posted by

Hi,
>
I am working on an Asp.net 2.0 web application that uses master pages,
according to our application architecture we should not use Viewstate. Is
there a work around to raise the events fired from the child controls of
repeater when viewstate is disabled?
>
The scenario is as follows
I have a web page with a repeater that has controls on it, The viewstate


is

Quote:

Originally Posted by

disabled. The repeater is data bound to an arraylist in the page_load
event(in block if !ISPostback), so when the user requests the page for the
first time the repeater is populated. There is a button in the repeater
which is used to add another row. When this button is clicked the event


will

Quote:

Originally Posted by

not be fired on the server on postback. this is because the repeater


itself

Quote:

Originally Posted by

is databound in the page load when its not Postback.
>
This works fine if we enable viestate, does any one know whether there is


a

Quote:

Originally Posted by

work around for this? any help is highly appreciated
>
Thank you
Vj
>


Hello Vijay,

VI am working on an Asp.net 2.0 web application that uses master
Vpages, according to our application architecture we should not use
VViewstate. Is there a work around to raise the events fired from the
Vchild controls of repeater when viewstate is disabled?

What if to use the ControlState to keep the info there, or it's the behaviour
by design not keep any client info?

--
WBR, Michael Nemtsev [.NET/C# MVP].
My blog: http://spaces.live.com/laflour
Team blog: http://devkids.blogspot.com/
"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

0 comments:

Post a Comment