Click here to Skip to main content
15,910,877 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am taking input image in this way and making it invisible on form load
<input type="image"  id ="img" name="img" style="display:none;"  runat="server" src="../Images/calendar.jpg" "  />

On certain condition i am making it visible/Invisible through javascript
After making it visible whenever i am clicking server side button or whenever form is getting postback it is getting invisible again
Posted
Updated 26-Jun-11 19:42pm
v2

Use Hidden variable to maintain visible / Insvisible flag. Also when ever postbacks check for flag and do display:none or display:block in the javascript
$(document).ready(function () {
  var manager = Sys.WebForms.PageRequestManager.getInstance();
  manager.add_endRequest(endRequest);
  manager.add_beginRequest(OnBeginRequest);

  if(hdnShowflag == true)
  {
    display:block
  }
  else
  {
    display:block
  }
});

function OnBeginRequest(sender, args) {
  if(hdnShowflag == true)
  {
    display:block
  }
  else
  {
    display:block
  }
}

function endRequest(sender, args) {
  if(hdnShowflag == true)
  {
    display:block
  }
  else
  {
    display:block
  }
}
 
Share this answer
 
v2
If you are using session management, store the state of the variable in a session and load it once the page reloads.
If you are unaware about state management, you might want to read about it in a book or msdn.
 
Share this answer
 

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