Sunday, May 19, 2024
Homepage · c#
 Popular · Latest · Hot · Upcoming
149
rated 0 times [  155] [ 6]  / answers: 1 / hits: 60318  / 12 Years ago, tue, june 5, 2012, 12:00:00

I have on my Page_Load registered this



 Page.ClientScript.RegisterStartupScript(this.GetType(), clientscript, document.getElementById('showdiv').style.visibility = 'hidden';, true);


But its not getting hidden... My div is as shown below



<div id=showdiv>
<input class=button type=button value=OK name=success_button id=my button onclick=javascript:window.close(); />
</div>


what am I doing wrong?. Thank you for your help


More From » c#

 Answers
15

I highly recommend doing this simple client side manipulation (show/hode rows controls, etc.) with JavaScript or even more easily with a .js library like jQuery. After you include the jQuery scripts in your application, this is all you need to do to have that DIV be hidden after the page has completed its initialization.



Include this script section at the top of your page or in a referenced .js file if you already have one:



<script type=text/javascript>

//$(document).ready is used to define a function that is guaranteed to be called only after the DOM has been initialized.
$(document).ready(function () {
//Hide the div
$('#showdiv').hide();
//conversely do the following to show it again if needed later
//$('#showdiv').show();
});

</script>


jQuery API documentation on this method:

http://api.jquery.com/hide/


[#85132] Monday, June 4, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
yosefleod

Total Points: 113
Total Questions: 100
Total Answers: 115

Location: Egypt
Member since Tue, May 3, 2022
2 Years ago
;