Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET: asp:LinkButton with Javascript disabled?

i want to use an asp:LinkButton, since it looks like a link, yet also has server-side Click handler.

But the web-server seems unable to detect if javascript is disabled on the client, and doesn't render into a mechanism that still works.

Is it possible to have a link that looks like a link, but has server-side OnClick event handler?


Answer

The answer is no, but below are some workaround ideas. Accepted the one with non-zero up-votes.

like image 790
Ian Boyd Avatar asked Jan 26 '09 16:01

Ian Boyd


People also ask

How to disable asp linkbutton in javascript?

getElementById("LinkButton1"). disabled = false;)

How to hide link Button using javascript?

Answers. you can't hide linkbutton using javascript , if your page is post back on any event, link button will appear again. make sure if you want your button click / any event to fired on sever, this will not give required result......


1 Answers

You could use CSS to style a button to look like a link, but this will be very much browser dependant, depending on the CSS implementation.


Edit: I feel compelled to complete my answer since it's been accepted.

An asp:LinkButton renders to an HTML link, and as such cannot post to a web page; but can only make get requests. To work around this MS use JavaScript to action the post. This is not possible however if Javascript is disabled.

asp:Button and asp:ImageButton are different. They submit the HTML form by posting to a web page (or get depending on the form attributes) by using true HTML form elements. So these will work without JS intervention.

Some browsers will allow CSS styling to style a button to look like a link, and as such this can be used to work around the issue.

like image 181
Ady Avatar answered Sep 19 '22 18:09

Ady