JS确认Ok&在gridview页面索引上取消 [英] JS Confirm Ok & Cancel on gridview page indexing

查看:77
本文介绍了JS确认Ok&在gridview页面索引上取消的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个gridview,在页面索引上我需要显示一个确认框警告,其中包含确定和取消。我在页面中有一个更新按钮,gridview有下拉值。当用户更改gridview中的下拉值并尝试移动到下一页而不单击更新按钮时,我需要显示一个警告,例如确保在导航之前更新了更改。我已经尝试了很多JS并没有任何帮助。



我在页面索引中使用了这段代码。弹出警报,但没有确认框,显示确定和取消。



  string  script =   alert('确保在导航前更新了页面!') ; 
ScriptManager.RegisterStartupScript(Page,Page.GetType(), Alert,脚本, true );





真的很感激任何帮助。

解决方案

嘿兄弟,



你需要使用带有确认和取消按钮的JavaScript的确认框默认情况下,您无法在JavaScript中更新警告框,而不是警报使用确认。



您也可以查看此文章:



http://www.c-sharpcorner.com/uploadfile/syedshakeer/how-to-show-alert-and-confirmation-message-box-in-Asp-Net/ [ ^ ]

 ScriptManager.RegisterStartupScript( this  typeof (< span class =code-keyword> string ),  ConfirmMessage  if(确认('确保您在导航前更新了页面!')){alert('OK');} else {alert('cancel');} true ); 


Hi,
I have a gridview and on Page Indexing I need to show an confirm box alert with Ok and Cancel. I have an update button in the page and gridview has dropdown values. When user changes the dropdown values in gridview and try to move to next page without clicking update button, then I need to show an alert like "Make sure you have updated the changes before navigation". I have tried lot of JS and nothing helped.

I am using this peice of code in my page indexing. The alert pops up but not the confirm box with Ok and Cancel.

string script = "alert('Make sure you have updated the page before navigation!')";
    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Alert", script, true);



Really appreciate any help on this.

解决方案

Hey Bro,

You need to use "Confirm Box" of JavaScript that have O.k and Cancel button by default, you can't update alert box in JavaScript so instead of alert use confirm.

You can check this Article as well:

http://www.c-sharpcorner.com/uploadfile/syedshakeer/how-to-show-alert-and-confirmation-message-box-in-Asp-Net/[^]


ScriptManager.RegisterStartupScript(this, typeof(string), "ConfirmMessage", "if(confirm('Make sure you have updated the page before navigation!')){alert('OK');}else{alert('cancel');}",true);


这篇关于JS确认Ok&amp;在gridview页面索引上取消的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆