How to get javascript confirm popup value in c#.net - Stack Overflow

I want to get javascript confirm popup returns value from code behind. Here when user select ok button

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
Add a ment  | 

4 Answers 4

Reset to default 5

On 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

相关推荐

  • How to get javascript confirm popup value in c#.net - Stack Overflow

    I want to get javascript confirm popup returns value from code behind. Here when user select ok button

    1天前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信