I have a function openbag(); for opening div. this div is also open on click and addClass “active”. but i am open this div from server side, call the function openbag();. but the problem is this div is open every time when refresh the other page. I have removed “active” class and check if class has not but this is always showing. here is my code i am using.
function openBag() {
$("#bag").addClass("active");
$("#expanding-bag").slideDown("fast");
}
$(document).ready(function () {
if ($("div#bag").hasClass("active")) {
$("#expanding-bag").show();
$("#bag").removeClass("active");
}
else {
$("#expanding-bag").hide();
}
in c# :
Page.ClientScript.RegisterStartupScript(typeof(Page), "alert", "<script language='javascript'>openBag();</script>");
You can avoid open it and close it and all that, and direct manipulate the javascript from code behind. One trick is to use Literal and show it or not, and place inside of it the code as:
and on code behind you make
ShowIt.Visible=true; in the one you wish to run.Other way is to direct render this code on page from code behind.