Events and Properties

S

shapper

Hello,

I would like some confirmation on events.

Should controls be added to page or to their parent controls in
Page.Load event wrapped by "If Not PostBack"?
And in which event should the general properties and data binding be
defined?

And where are the values of class properties defined?

I have been working a few classes and web controls.
I notice a few problems like some action not firing or a few custom
class properties not getting their values.

Just need to clarify this.

Any link would be great to.

Thanks,
Miguel
 
B

bruce barker

depends on if you use viewstate or not.

if you use viewstate (bad practice), then you should use if(!Postback).

if you turn off viewstate, then the code belongs in oninit and should
always be done.

note: just before oninit is when asp.net creates its controls and set
their properties (the controls defined in the aspx page).

-- bruce (sqlwork.com)
 
S

shapper

depends on if you use viewstate or not.

if you use viewstate (bad practice), then you should use if(!Postback).

if you turn off viewstate, then the code belongs in oninit and should
always be done.

note: just before oninit is when asp.net creates its controls and set
their properties (the controls defined in the aspx page).

-- bruce (sqlwork.com)

But if ViewState holds data between PostBacks, right? Like controls
properties?
What I mean is what happens if I turn View State off and make
MyPanel.Visible = False?

I am not sure but If I turn ViewState off isn't something like making
pages that don't inherit from Page class?
Something like not taking advantage of a few of ASP.NET features?

Thanks,
Miguel
 
S

shapper

But if ViewState holds data between PostBacks, right? Like controls
properties?
What I mean is what happens if I turn View State off and make
MyPanel.Visible = False?

I am not sure but If I turn ViewState off isn't something like making
pages that don't inherit from Page class?
Something like not taking advantage of a few of ASP.NET features?

Thanks,
Miguel

I will improve performance, by decreasing page load, by turning
viewstate off.

Just a few questions:

1. If page controls values are defined at start then I can turn off
page viewstate.
So:
I can add and define all my controls at Page.Init event?
Does this include if a few control properties, as text, are taken
from a data source?

2. If I have a GridView with paging I need to have viewstate on?
3. And if GridView is inside an Ajax Update Panel?

Thanks,
Miguel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top