dotnet thoughts 

a dotnet developer's technical blog

Javascript confirm dialogs from link buttons of Datagrid

If you are using DataGrid or GridView in ASP.Net, we may require to display a confirmation, like when you are deleting a record. This code will help to display confirmation dialogs from Client side, with ASP.Net Datagrid control or Gridview control etc.

<span onclick="return confirm('Are you sure you want to delete this record?');">
<asp:linkbutton runat="server" id="Delete" CommandName="Delete"
commandArgument='<%#Container.DataItem("field")%>' Text="Delete" />
</span>

Disable right click with Javascript

Here is two javascript code, helps you to disable right click, on webpages with Javascript.

function NoRightClick() {
if (event.button == 2)
{
alert("This action is not possible")
}
}
document.onmousedown=NoRightClick;

Or you can simply use.

<body oncontextmenu="return(false);">

This second code works only in Microsoft Internet Explorer.

« Newer Posts