LoadViewState does not fire on a postback event

Ask a Question related to ASP.NET Building Controls, Design and Development.

  1. #1

    Default LoadViewState does not fire on a postback event

    Hi there,

    I need some help please. I have created a composite control that have a
    collection of items associated with it. Now I want to save this to the view
    state of the control, but the LoadViewState method does not get called so I
    can get the collection out of the view state.

    Does anybody have any idee why this is happening?

    Regards,
    Jean


    Jean Erasmus Guest

  2. Similar Questions and Discussions

    1. composite control does not fire event
      Hi I have an aspx-page, where I load my custom-control (see below). The problem I have is that the event does not fire. I really cant figure out...
    2. datagrid linkbutton will not fire Postback at random times
      I have a simple linkbutton in a datagrid that works 99.99% of the time. At random times (4 times in the past year) with non-specific data records, a...
    3. Checkbox in Datagrid doesn't fire event
      I've added a Checkbox control to a Datagrid and would like to Enable/Disable a button based on whether the checkbox is checked. However, I'm trying...
    4. Bug in _EditCommand, event didn't fire? +my solution
      Hello, I had a problem that the _EditCommand didn't fire when the event was created in the .vb code. I did like this: 1. I created a datagrid...
    5. how to fire a postback event
      Hi, All I design a composite custom control, which has three dropdownlists in it. I find as long as one of the dropdownlist control's id is...
  3. #2

    Default Re: LoadViewState does not fire on a postback event

    Hi Jean,

    A very common cause for viewstate to not be loaded it late addition to the
    control tree. Is your composite being added dynamically or is it declared at
    design-time? What about its childrens?

    --
    Victor Garcia Aprea
    Microsoft MVP | ASP.NET
    Looking for insights on ASP.NET? Read my blog:
    [url]http://obies.com/vga/blog.aspx[/url]

    To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
    "Jean Erasmus" <jeane@trenstar.co.za> wrote in message
    news:O1LgCR0sDHA.2252@TK2MSFTNGP09.phx.gbl...
    > Hi there,
    >
    > I need some help please. I have created a composite control that have a
    > collection of items associated with it. Now I want to save this to the
    view
    > state of the control, but the LoadViewState method does not get called so
    I
    > can get the collection out of the view state.
    >
    > Does anybody have any idee why this is happening?
    >
    > Regards,
    > Jean
    >
    >

    Victor Garcia Aprea Guest

  4. #3

    Default Re: LoadViewState does not fire on a postback event

    Hi Victor,

    I found the problem. I was using an inherited page class, and the control
    was being loaded before the base.OnInit was called.

    Regards,

    Jean

    "Victor Garcia Aprea" <vga@obies.com> wrote in message
    news:%23Cov2a9sDHA.1884@TK2MSFTNGP10.phx.gbl...
    > Hi Jean,
    >
    > A very common cause for viewstate to not be loaded it late addition to the
    > control tree. Is your composite being added dynamically or is it declared
    at
    > design-time? What about its childrens?
    >
    > --
    > Victor Garcia Aprea
    > Microsoft MVP | ASP.NET
    > Looking for insights on ASP.NET? Read my blog:
    > [url]http://obies.com/vga/blog.aspx[/url]
    >
    > To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
    > "Jean Erasmus" <jeane@trenstar.co.za> wrote in message
    > news:O1LgCR0sDHA.2252@TK2MSFTNGP09.phx.gbl...
    > > Hi there,
    > >
    > > I need some help please. I have created a composite control that have a
    > > collection of items associated with it. Now I want to save this to the
    > view
    > > state of the control, but the LoadViewState method does not get called
    so
    > I
    > > can get the collection out of the view state.
    > >
    > > Does anybody have any idee why this is happening?
    > >
    > > Regards,
    > > Jean
    > >
    > >
    >
    >

    Jean Erasmus Guest

  5. #4

    Default Re: LoadViewState does not fire on a postback event

    Quote Originally Posted by Jean Erasmus View Post
    Hi there,

    I need some help please. I have created a composite control that have a
    collection of items associated with it. Now I want to save this to the view
    state of the control, but the LoadViewState method does not get called so I
    can get the collection out of the view state.

    Does anybody have any idee why this is happening?

    Regards,
    Jean
    // I added this SaveViewState event. and after post back the LoadViewState will be called.//
    //Working fine now.
    protected override object SaveViewState()
    {
    ViewState["MyKey"] = "My Value";
    Response.Write("SaveViewState <br>");
    return ViewState["MyKey"];
    }

    protected override void LoadViewState(object sender)
    {
    Response.Write("LoadViewState <br>");
    }
    protected override void LoadViewState(object sender)
    {
    Response.Write("LoadViewState <br>");
    }
    Unregistered Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139