I want to get javascript
confirm popup returns value from code behind. Here when user select ok button on confirm popup some code goes here, or user select cancel button on the popup some code goes here.
How to get the selected value from code behind?
My code is;
if (ClientScript.RegisterStartupScript(typeof(Page), "Confirm", "<script type='text/javascript'>return Confirm('Do you Want to Delete');</script>"))
{
db.Deletedevicedate();
clear();
}
else
{
clear();
}
I want to get javascript
confirm popup returns value from code behind. Here when user select ok button on confirm popup some code goes here, or user select cancel button on the popup some code goes here.
How to get the selected value from code behind?
My code is;
if (ClientScript.RegisterStartupScript(typeof(Page), "Confirm", "<script type='text/javascript'>return Confirm('Do you Want to Delete');</script>"))
{
db.Deletedevicedate();
clear();
}
else
{
clear();
}
Share
Improve this question
edited Jun 14, 2013 at 8:52
greg
1,3142 gold badges14 silver badges33 bronze badges
asked Jun 14, 2013 at 8:49
Gajulapalle.rajeshGajulapalle.rajesh
593 silver badges14 bronze badges
4 Answers
Reset to default 5On your client click event try this
OnClientClick = " return confirm('Do you want to proceed ?');"
Example:
<asp:Button runat="server" OnClientClick = " return confirm('Do you want to proceed ?');" />
if they click ok only then the button click event is called or else a page postback wont happen.Write your code to delete data in the button click.
Try to use ajax.
javascript section
var result = confirm("Do you Want to Delete?");
if (result)
{
//do ajax call and delete from database
return true;
}
else
{
return false;
}
In order to get this working with minimal changes to your code, I would add a hidden field to your page (that you can get the value of in your code-behind) and set the value of this field using JavaScript:
<script type='text/javascript'>$('#yourhiddenfield').val(Confirm('Do you Want to Delete'));</script>
if
{
ImageButton BtnDelete = (ImageButton)e.Row.FindControl("btnDelete");
BtnDelete.Attributes.Add("onclick", "javascript:return confirm('Delete this payment method?');");
}
else
{
// No Alert here or additional functionality
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744724023a4590079.html
评论列表(0条)