0

Dears we have .net page has Update panel

        <asp:UpdatePanel runat="server" ID="upMain" UpdateMode="Always">
            <ContentTemplate>
                <table style="width: 100%">
                    <tr>
                        <td>
                            <common:Message runat="server" ID="ucMessage" />
                        </td>
                    </tr>
                </table>
                <common:JalsaStatmentView runat="server" id="JalsaStatmentView" />
            </ContentTemplate>
        </asp:UpdatePanel>
        <asp:UpdateProgress runat="server" AssociatedUpdatePanelID="upMain" ID="uppMain" DisplayAfter="1">
            <ProgressTemplate>
                <div class="divWaiting">
                    <img src="/Design/images/loading.gif" height="120" width="120" />
                </div>
            </ProgressTemplate>
        </asp:UpdateProgress>
    </div>

when we try to edit the page by this code

        txtIdea.ReadOnly = ISActive;
        txtIdea.CssClass = CSSClass;
        txtStatement.ReadOnly = ISActive;
        txtStatement.CssClass = CSSClass;
        txtSubject.ReadOnly = ISActive;
        txtSubject.CssClass = CSSClass;
        chkIsResolved.Enabled = !ISActive;

it's work normal, but when i assign the list to view state after that the page keep its state and not change to edit mode

        txtIdea.ReadOnly = ISActive;
        txtIdea.CssClass = CSSClass;
        txtStatement.ReadOnly = ISActive;
        txtStatement.CssClass = CSSClass;
        txtSubject.ReadOnly = ISActive;
        txtSubject.CssClass = CSSClass;
        chkIsResolved.Enabled = !ISActive;

       List<RequestAttachment> AttachmentList = new List<RequestAttachment>();//dbContext.RequestAttachment.GetByQuery(x => x.EntryTypeId == 2 && x.EntryId == statementID && x.UpdatedBy != HttpContext.Current.User.Identity.Name).ToList();
                        ViewState.Add("AttachmentList", AttachmentList);//AttachmentList;

when i add the last tow rows to our code the page not work and stay in view mode

  • when we change the assign to string like that

    ViewState.Add("AttachmentList", "Hello");//AttachmentList;

    the page work again and changed to the edit mode ,

My problem why when i add List of object to view state the page not change its mode

AHMAD
  • 95
  • 11
  • What is the size of that AttachmentList (number of items, size of the items)? – Hans Kesting Jan 13 '16 at 12:32
  • Also see here: http://stackoverflow.com/questions/13437820/how-to-store-list-of-object-into-viewstate – Hans Kesting Jan 13 '16 at 12:38
  • Dear as you can see, we only defined the AttachmentList and added to view state then not work, if the AttachmentList has 0 item or 1 or more not working, i serialized the AttachmentList object as string and after added it to view state then the page worked fine, the problem only when i add object in view state – AHMAD Jan 13 '16 at 16:24

0 Answers0