<asp:LinkButton ID="lnkRemove" runat="server" CommandArgument='<%# Eval("CustomerID")%>' OnClientClick="return validateLink()" Text="Delete" OnClick="DeleteCustomer"></asp:LinkButton>
function validateLink() { PageMethods.getSqlCountAjax(onRequestComplete, onError); // call to yr AJAX function to get sql count function onRequestComplete(result) { var sqlCount = result; if (sqlCount > 5) { return true; } else if (sqlCount >= 3 || sqlCount <= 5) { if (confirm('yr confirmation mesaage here...') == 1) { return true; } } else { alert('not allowed to navigate to this page'); return false; } return false; } }
<WebMethod()> <ScriptMethod()> Public Shared Function sqlCountAjax() As Integer Dim strConnString As String = ConfigurationManager.ConnectionStrings("conString").ConnectionString Dim strQuery As String = "select Count(*) As number from customers" Dim cmd As New SqlCommand(strQuery) cmd.CommandType = CommandType.Text Dim con As New SqlConnection(strConnString) con.Open() Dim records As Integer Return (records = CInt(cmd.ExecuteScalar)) con.Close() End Function
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)