c# - Javascript function to hide HTML textbox on PageLoad -
so have search textbox @ top of website in master page wish disappear when user transferred search page. textbox written so:
<div class = "searchbox"> <form action="javascript:searchsite()"> <input type="text" id="searchin" /> </form> </div> the best way think have javascript run on pageload event of search page, so:
protected void page_load(object sender, eventargs e) { if (!ispostback) { this.clientscript.registerstartupscript(this.gettype(), "show", "<script>document.getelementbyid('searchin').style.display = 'none'</script>"); } } i javascript works, because textbox disappear second or two. regardless, comes , won't remain hidden. have asp:textbox can hide using:
site1 m = master site1; m.othertextbox.visible = false; i don't understand why hiding html textbox difficult. suggestions or thoughts on how remedy appreciated!
page_load server-side event, have wait element loaded on client side. can wrap js code in window.onload handler:
this.clientscript.registerstartupscript(this.gettype(), "show", "<script>window.onload = function() { document.getelementbyid('searchin').style.display = 'none'; }</script>"); also, use display: none explained slaks.
Comments
Post a Comment