如何在asp.net内容页面中使用javascript显示确认消息框? [英] how to display confirm message box using javascript in asp.net content page?

查看:54
本文介绍了如何在asp.net内容页面中使用javascript显示确认消息框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在页面加载事件上绑定用户数据。如果用户更改数据并单击保存按钮,则使用javascript确认消息显示给用户。如果用户单击确定按钮,则数据在数据库中更新,如果用户单击取消按钮数据未在数据库中更新。



问候,

Manohar

解决方案

请参阅

< asp:button id =   save_detail runat =   server text =  保存 onclick =   save_detail_Click onclientclick = < span class =code-string>  return confirm('您确定要保存所选记录吗?'); /> 



如果您单击是,则只会调用 OnClick 事件。



问候..


 <   script     type   ='  text / javascript' >  
document.getElementById(someButtonId )。onclick = function(){
var confirmation = window.confirm(你确定吗?); //确认变量将包含true / false。

if(确认){/ *编写代码为* * /}
else {/ *编写代码为否* /}
}
< / script >





尝试此代码


请参阅此内容,以确认消息。

< asp:按钮runat =   server Text =  立即尝试 OnClientClick =   if(确认('格式化硬盘?'))
alert('你非常勇敢!');
else alert('一个明智的决定!')
style = font-weight:700;颜色:#006666
宽度= 84px />



谢谢Ú


i am binding user data on page load event.if user change data and click on save button than confirm message display to user using javascript.if user click on OK button then data get updated in database and if user click on cancel button data not updated in database.

regards,
Manohar

解决方案

See this

<asp:button id="save_detail" runat="server" text="Save" onclick="save_detail_Click" onclientclick="return confirm('Are you sure you want to save selected records?');" />


If you click yes then only OnClick event will get called.

Regards..


<script type='text/javascript'>
    document.getElementById("someButtonId").onclick = function() {
        var confirmation = window.confirm("Are you sure?"); //confirmation variable will contain true/false.

        if(confirmation) { /* Write code for Yes */ }
        else { /* Write code for No */ }
    }
</script>



try this code


See this one, for confirm msg.

<asp:Button runat="server" Text="Try it now" OnClientClick="if(confirm('Format the hard disk?'))
alert('You are very brave!');
else alert('A wise decision!')" style="font-weight: 700; color: #006666"
            Width="84px" />


Thank u.


这篇关于如何在asp.net内容页面中使用javascript显示确认消息框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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