[Solved]Confirmation Box Problem [modified]
-
try to add itemtemplate in gridview and do it
<ItemTemplate>
<asp:LinkButton ID="Delete" CommandName="Delete" OnClientClick="return confirm('Are you sure you wish to delete this item?')" CausesValidation="false" runat="server" Text="Delete" ></asp:LinkButton> </ItemTemplate>
If It Helps Click It as Answer
hey thanks man, its working alright. :-D
-
i am using ItemTemplate rite now :) Let me try with that OnClientClick.
-
hey thanks man, its working alright. :-D
-
hey thanks man, its working alright. :-D
nagendrathecoder wrote:
, its working alright.
Then you should
vote / Rate
his answer which helps you :)Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.
-
nagendrathecoder wrote:
, its working alright.
Then you should
vote / Rate
his answer which helps you :)Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.
I did it. ;)
-
Hello All, In my ASP.Net application, i am showing a confirmation box using javascript whenever user intends to delete something. I have written this code in aspx file
function confirmation()
{
if(confirm("Are you sure?")==true)
return true;
else
return false;
}Then on Page_Load of my codebehind, i am using this:
btnDelete.Attributes.Add("onclick", "return confirmation();")
It is working fine, if user click ok record is deleting and vice versa. But when i am trying to write same thing for my GridView delete link its not working, i am writting this:
GridView1.Attributes.Add("OnRowDeleting", "return confirmation();");
Can anybody help me? why its not working for GridView_RowDeleting method? Thanks, Nagendra.
modified on Thursday, September 24, 2009 7:06 AM
The same thing will work here. actually you are not adding it at correct place. First of all, u are adding the attribute to Grid view. In fact when u wanna delete any item then i m sure u have placed some control in each row on clicking of that , that particular item will be deleted. So if it is a LinkButton/Button in ItemTemplate then you can add the attribute to it onRowDataBound Event or RowCreated Event or OnClientClick Property itself.
OR
ImageButton btn = (ImageButton)(e.Row.FindControl("imgbtnDelete"));
btn.Attributes.Add("OnClientClick","funcationToBecalled();") -
The same thing will work here. actually you are not adding it at correct place. First of all, u are adding the attribute to Grid view. In fact when u wanna delete any item then i m sure u have placed some control in each row on clicking of that , that particular item will be deleted. So if it is a LinkButton/Button in ItemTemplate then you can add the attribute to it onRowDataBound Event or RowCreated Event or OnClientClick Property itself.
OR
ImageButton btn = (ImageButton)(e.Row.FindControl("imgbtnDelete"));
btn.Attributes.Add("OnClientClick","funcationToBecalled();")Nisha Agrawal wrote:
ImageButton btn = (ImageButton)(e.Row.FindControl("imgbtnDelete")); btn.Attributes.Add("OnClientClick","funcationToBecalled();")
Hmmm, this is also working. Thanks to u too. :)
-
Nisha Agrawal wrote:
ImageButton btn = (ImageButton)(e.Row.FindControl("imgbtnDelete")); btn.Attributes.Add("OnClientClick","funcationToBecalled();")
Hmmm, this is also working. Thanks to u too. :)
-
ofcourse :laugh: ;P
-
I did it. ;)
Thanks !
Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.