[Solved]Confirmation Box Problem [modified]
-
nagendrathecoder wrote:
function confirmation() { if(confirm("Are you sure?")==true) return true; else return false; }
This is messy as hell. Why not just return (confirm("Are you sure?")) ? Why not tell them what they are to be sure if, in case they don't realise what they pushed ?
nagendrathecoder wrote:
GridView1.Attributes.Add("OnRowDeleting", "return confirmation();");
I'd guess that it's because you're trying to hook up to a code behind event, not an actual client side event. You could start by reading on the difference between the client and server.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
Thanks, i implemented what u mentioned(used just confirm & displaying proper msg). :) I also understand that RowDeleting is server side event and onclick is client side. But i want this functionality to work for GridView too, what can i do?
-
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
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
-
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
i am using ItemTemplate rite now :) Let me try with that OnClientClick.
-
i am using ItemTemplate rite now :) Let me try with that OnClientClick.
-
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
-
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.