News Headlines

Monday, December 15, 2008

How to show alert and then confiramtion?



This function gives
an alert if no item was selected in gridview.



After selecting
it asks for confiramtion to delete.






var
BaseGrid = null;




window.onload = function()


{

try


{

BaseGrid =
document.getElementById('<%= this.gvSubmit.ClientID
%>'
);


}

catch(err)

{


BaseGrid = null;

}

}

function SelectAnItemToDelete()

{
var isch=false;
if(BaseGrid == null)
{


return
false;

}

var ChildControl
= "rbtnItemList";
var Inputs =
BaseGrid.getElementsByTagName("input");
for(var
n = 0; n < Inputs.length; ++n)


{


if(Inputs[n].type
== 'radio' && Inputs[n].id.indexOf(ChildControl,0)
>= 0 && Inputs[n].checked)


{


isch=true;

return confirm('Are you sure want to Delet ?');
}


}



if(!isch)

{

alert('Please
select at least one Item!'
);

return
false;


}

}




Call the above function
like..

OnClientClick="javascript:return SelectAnItemToDelete();"

No comments: