Solved

jQuery Toolkit & ASP.NET postback

Posted on 2010-11-29
3
600 Views
Last Modified: 2012-05-10
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
Comment
Question by:nkewney
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 19

Assisted Solution

by:Bardobrave
Bardobrave earned 150 total points
ID: 34229306
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
 
LVL 14

Assisted Solution

by:Dushyant Sharma
Dushyant Sharma earned 150 total points
ID: 34229604
to store the state you can use cookies. jquery has cookies plugin available.
0
 
LVL 20

Accepted Solution

by:
Proculopsis earned 200 total points
ID: 34230674

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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question