hello guys
i am creating a project in asp.net
and is that project i need to delete record with confirm box
for example, if i press the delete button then confirm box show me this msg like "Are you sure you want to delete" if i press OK then delete that record and if i press Cencel then record will not delete ....
so plz help me and guide me and provide me the source code about perticuler task if u can ...
Thanks.
Loading




Ankit NandekarRank #703 · 3.4K reputationPosted Apr 14, 2011, 10:34 PM EDT
onclientclick="return confirm('Are you sure want to delete current record')"
for example if you are using link button for delete then write
Ravishankar SinghRank #669 · 3.6K reputationPosted Apr 14, 2011, 11:18 PM EDT
You can also use below code in ur code behind:
string strConfirmation="Are you sure you want to delete?";
btnRemove.Attributes.Add("onclick", "javascript:if(confirm('"+strConfirmation+"')== false) return false;");
Hope this code will solve your problem. :)
Faisal AnsariRank #3,366 · 427 reputationPosted Apr 14, 2011, 11:48 PM EDT
your code is working and benefital for me :)
by the way where were you? issay pehley wala question bhi ap sey poocha tha main ney...
actually your examples i can understand easily.. so can you please give me your personal ID that i able to contact u there and get solutions about my problems ...
thanks ...
Ravishankar SinghRank #669 · 3.6K reputationPosted Apr 15, 2011, 12:02 AM EDT
Faisal AnsariRank #3,366 · 427 reputationPosted Apr 15, 2011, 12:09 AM EDT
i will get you..
but here is one problem with me
actually i want to do this like that
but the Error : Operator '==' cannot be applied to operands of type 'void' and 'bool'
so how can i come over for it ...?
Thanks.
Suthish NairRank #92 · 22.8K reputationPosted Apr 15, 2011, 12:27 AM EDT
Because in future if you want to change the Confirmation message, you need to change in code-behind resulting in
uploading of dlls again.
On Page Load
btn1.Attributes.Add("onclick", "javascript:if(DeleteMe()==false) {return false;};");