I am having a RadButton control placed outside the grid ,to delete the multiple selected rows from the grid ,
i have written Client side and Server Side Validation Functions to show Pop-Up if User clicks on Delete Button
without selecting any row from the grid saying "Please select item(s) to delete.!!" using Alert().
on doing so ,my Javascript Function gets executed and gives me the desired Alert PopUp ,on clicking ok button of the PopUp it does PostBack which causes Server Side Validation to fire,
Due to which i am getting 2 PopUps one from Client Side and another From Server Side Code one after the other.
Javascript Function is given below :-
function DeleteSelectedItems(sender, args) {
var Count=0;
var grid = $find("<%=grdSearchResults.ClientID %>");
var masterTable = grid.get_masterTableView();
for (var i = 0; i <
masterTable.get_dataItems
().length; i++) {
var
gridStatementElement
=
masterTable
.get_dataItems()[i].findElement("chkSelect");
if (gridStatementElement != null && gridStatementElement.checked==true) {
Count
= Count + 1;
}
}
if (Count == 0) { //This part is not working fine
alert("Please select item(s) to delete.!!") ;
return false;
}
else if(Count>0){ //This is working Fine
ConfirmDeletion(sender, args);
}
Call to Javascript method from RadButton :-
<
telerik:RadButton
ID
=
"btnDelete"
runat
=
"server"
Visible
=
"false"
Text
=
"Delete"
OnClick
=
"btnDelete_Click"
OnClientClicking
=
"DeleteSelectedItems"
>
<
Icon
PrimaryIconUrl
=
"../Images/Common/Delete-icon.png"
/>
</
telerik:RadButton
>
I want to stop this additional PostBack so that my Server side validation will not fire.