Events and Properties

Discussion in 'ASP .Net' started by shapper, Oct 15, 2007.

  1. shapper

    shapper Guest


    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

    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.

    shapper, Oct 15, 2007
    1. Advertisements

  2. shapper

    bruce barker Guest

    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 creates its controls and set
    their properties (the controls defined in the aspx page).

    -- bruce (
    bruce barker, Oct 16, 2007
    1. Advertisements

  3. shapper

    shapper Guest

    But if ViewState holds data between PostBacks, right? Like controls
    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?

    shapper, Oct 16, 2007
  4. shapper

    shapper Guest

    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.
    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?

    shapper, Oct 16, 2007
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.