Click here to Skip to main content
15,912,329 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i'm using jquery to collapse and expand a some div tags in my page..

my problem is that if i have a div that is collapsed and i fire an event in the back end code the page refreshes and the div expands... does anyone have any idea how can i fix this?

note that i'm using asp.net with vb.net

VB
<div class="content-module-heading cf">
   <h3 class="fl">Table of content to send</h3>
   <span class="fr expand-collapse-text">Click to collapse</span>
   <span style="display: none;" class="fr expand-collapse-text initial-expand">Click to expand</span>
</div> 


jquery:

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

//Content boxes expand/collapse
$(".initial-expand").hide();

$("div.content-module-heading").click(function(){
    $(this).next("div.content-module-main").slideToggle();

    $(this).children(".expand-collapse-text").toggle();
});

 });
Posted

See this link. It might be helpful.

SlideToggle on multiple divs to maintain state during postbacks[^]

Regards..
 
Share this answer
 
Hey there,

You can create a function like:
JavaScript
function myFunction(){
    $("div.content-module-heading").next("div.content-module-main").slideToggle();
    $("div.content-module-heading").children(".expand-collapse-text").toggle();

}
and register the script to call this function inside the event, like:
C#
Page.ClientScript.RegisterStartupScript(GetType(), "YourKey", "myFunction();", true);


Hope it helps.

Azee...
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900