Sheetal Inani
Sheetal Inani

Reputation: 128

I want to disable hyper link after clicking on it

I have a link

<asp:HyperLink ID="BtnPrint" runat="server"NavigateUrl="~/CrystalReportViewer.aspx" 
     Visible="false" Target="_blank" ToolTip="Print pdf">Print</asp:HyperLink>

I want that when I click to show it should be visible.. that's working... but I want that when I click to this hyper link it should be invisible or not enabled...

or is it possible to show page in new tab or window by using asp button or asplinkbutton?

Upvotes: 0

Views: 7057

Answers (5)

Arafa
Arafa

Reputation: 1

Try this :

`$(document).ready(function() {
    $('#BtnPrint').click(function() {
          $(this).prop("disabled", true);
    });
});
`

Upvotes: 0

Daniel Dyson
Daniel Dyson

Reputation: 13230

Try this in your code behind

    protected void Page_Load(object sender, EventArgs e)
    {
        BtnPrint.Attributes.Add("onclick","this.style.display='none';");
    }

This will set your link to invisible after it is clicked.

If you really want to disable the link, it is kind of complicated. This is because hyperlinks don't support the disabled attribute in all browsers. Have a look at this idea from Microsoft Support

Upvotes: 0

anish
anish

Reputation: 325

You can try

<a href="http://www.example.com" onclick="return false">

Upvotes: -1

Prasanna Narayanan
Prasanna Narayanan

Reputation: 439

You can hide the hyperlink using simple javascript's visible property.

Upvotes: -1

asawyer
asawyer

Reputation: 17808

Are you sure the user will not cancel the print on accident and need to reclick the link?

<a href="#" onclick="this.disabled=true">test</a>

or in code

myPrintLink.Attributes.Add("onclick", "this.disabled=true")

Upvotes: 4

Related Questions