[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 604
  • Last Modified:

jQuery Toolkit & ASP.NET postback

Dear Experts,

I'm using a snippet of jQuery to reveal a notes box on an ASP.NET application page, but when I post the page back, I lose the state of the box and it appears with its raw controls.

Could anybody suggest a way to maintain the state of the box when the page is posted back.  Here is the code I'm using:


jQuery(document).ready(function ($) {

        $("#note-content").expandable({ // all available options:
            startopen: false,
            title: "Quick Notes Panel",
            uiIconClosed: "icon-closed",
            uiIconOpen: "icon-open",
            animationClose: { height: "hide" },
            animationOpen: { height: "show" },
            open: function (event, options) {
            },
            close: function (event, options) {
            }
        });




  <asp:PlaceHolder ID="plcQuickNote" Visible="false" runat="server">
            <div id="note-content" class="note_float">
                <div class="top-5-notes">
                    <asp:Literal ID="litLast5Notes" runat="server"></asp:Literal>
                </div>
                <div class="rest-notes">
                <asp:Literal Visible="false" ID="litResult" runat="server"></asp:Literal></div>
                <GAC:StdTextBox Font-Size="11px" TextMode="MultiLine" Rows="4" Width="218px" ID="txtNoteBox"
                    runat="server"></GAC:StdTextBox><asp:ImageButton ID="ibNoteSubmit" ImageUrl="~/img/save_quick_note.gif"
                        runat="server" />
                <asp:ImageButton ID="ibRefresh" ImageUrl="~/img/refresh_only.gif" Visible="false"
                    runat="server" />
                    
            </div>
        </asp:PlaceHolder>

Open in new window

0
nkewney
Asked:
nkewney
3 Solutions
 
BardobraveCommented:
You can post the state back to your server with the rest of the data, and return it to client code into a hidden input where your jquery can read the current state it should use.
0
 
Dushyant SharmaCommented:
to store the state you can use cookies. jquery has cookies plugin available.
0
 
ProculopsisCommented:

You can transmit the state in your code behind via an attribute on the div:

<div id="note-content" state="open"...

and pick it up with:

$("#note-content").attr("state")

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now