|
-
June 22nd, 2010, 09:36 AM
#1
Confirmation of delete for a drop down..
Hello All,
I have a problem in a project i am doing. Can any1 please help me in this.
I have a drop down list as follows :
Code:
<asp:DropDownList ID="PostActionDDL" runat="server" EnableViewState="false" OnSelectedIndexChanged="activeRegistrant_SelectedIndexChanged"
AutoPostBack="true" >
<asp:ListItem Value="0">Select an Action</asp:ListItem>
<asp:ListItem Value="1">View</asp:ListItem>
<asp:ListItem Value="2">Delete</asp:ListItem>
</asp:DropDownList>
And i have the C# code as follows :
Code:
protected void activeRegistrant_SelectedIndexChanged(object sender, EventArgs e)
{
///Some code..
int selectedAction = Convert.ToInt32(dropList.SelectedValue);
switch ((RegistrationActions)selectedAction)
{
case RegistrationActions.View:
Response.Redirect("RegistrantDetails.aspx?id=" + registrationId.ToString());
break;
case RegistrationActions.Delete:
DeleteRegistration(registrationId);
//some code...
break;
}
}
Now, everything here is fine and working. But now, if the user selects delete, the data is getting deleted correctly. But without any confirmation. So, if a user selects the delete in the drop down list, i want a pop up to ask " Are you sure you want to delete ?"
And, if the user clicks view, i don't need any pop up.
Can any1 please help me...
Thanks
Last edited by laptop545; June 22nd, 2010 at 10:38 AM.
-
June 23rd, 2010, 01:48 AM
#2
Re: Confirmation of delete for a drop down..
You need to assign a javascript for your and show a confirm and return that result from your script.
If the user then clicks no/cancel - false is returned and the event is not send to the server.
So I would guess something like this in your code behind would work ( - although it might need some tinkering, this is off the top of my head)
Code:
PostActionDDL.Attributes.Add("onChange", "return confirm('Are you sure?');");
or add it in your markup
-
June 25th, 2010, 06:47 PM
#3
Re: Confirmation of delete for a drop down..
not Agreed,
this will cause the the confirm appear even if the user didn't chose the delete
so you need OnChange as Alsvha said,
but you need actually to call a JavaScript function
and chick the value of the DropDownList if it was Delete Show the Confirm
-
June 26th, 2010, 04:12 AM
#4
Re: Confirmation of delete for a drop down..
 Originally Posted by avrail
not Agreed,
this will cause the the confirm appear even if the user didn't chose the delete
so you need OnChange as Alsvha said,
but you need actually to call a JavaScript function
and chick the value of the DropDownList if it was Delete Show the Confirm
Same systematic, and you can just add the drop down check into the onChange return statement.
-
July 1st, 2010, 05:41 PM
#5
Re: Confirmation of delete for a drop down..
 Originally Posted by Alsvha
Same systematic, and you can just add the drop down check into the onChange return statement.
great,
You Don't Have to Rate Me.
I'm Not a Civilized Man I'm the Civilization it self
White or Black, Living or Dieing and 0 or 1 that's MY life
iam an Object in Object Oriented Life
010011000111010101110110001000000100110101111001001000000101000001100011 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|