Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a button not show up but still be used by javascript?

I am using a button that has to be invible and should be used by a javascript function.

<asp:Button ID ="btnDummy1" runat="server" Visible ="true" OnClick="btnSubmit1_Click" width="0px" height="0px"/

I cannot keep visible = false as it the javascript will not use invible content in the poage. I havetried to give width=0 and height=0, still it showws up in Chrome. What do you guys think i should do?

Thanks in advance :)

like image 590
challengeAccepted Avatar asked Dec 20 '10 13:12

challengeAccepted


People also ask

How do you invisible a button?

To make the button completely invisible, I set "cursor" to be default, so even when hovering over the button's location, the cursor will never change to a hand.

How do you make a button disappear in HTML?

hide(); document. getElementById('ButtonID'). style.


2 Answers

A pretty clean approach in ASP.Net it give it a "hidden" class:

<asp:Button ID ="btnDummy1" runat="server" CssClass="hidden" />

Then in your stylesheet:

.hidden { display: none; }
like image 58
Nick Craver Avatar answered Oct 21 '22 06:10

Nick Craver


If you set it to Visible="False" then the code will not be executed.

Instead I think you should wrap it in a <div> and set display:none via css:

<div style="display: none;">
   <asp:Button ID ="btnDummy1" runat="server" OnClick="btnSubmit1_Click" />
</div>
like image 27
rtpHarry Avatar answered Oct 21 '22 06:10

rtpHarry