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 po开发者_开发百科ssible to show page in new tab
or window
by using asp button or asplinkbutton
?
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")
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
Try this :
`$(document).ready(function() { $('#BtnPrint').click(function() { $(this).prop("disabled", true); }); }); `
You can hide the hyperlink using simple javascript's visible property.
You can try
<a href="http://www.example.com" onclick="return false">
精彩评论