2单击asp.net中的按钮时的确认消息 [英] 2 Confirmational messages when clicking on button in asp.net
问题描述
嗨朋友们,
我使用的是VS 2005,C#.net,ASP.NET。
我有一个网络应用程序。
点击一个按钮时,我需要收到一条确认信息。
如果是,则第二条确认信息必须到来。
如果第二个是肯定的一个功能必须执行C#服务器端代码
提前致谢
Geroge
Hi Friends,
I am using VS 2005,C#.net,ASP.NET.
I have a web application.
When clicking of a button,I need to get one confirmation message .
If it is yes, then second confirmation message has to come.
IF second is yes One function in C# server side code has to be executed
Thanks in advance
Geroge
推荐答案
嘿那里,
查看这个简单的例子来实现你想要的:
Hey there,
Check this simple example to achieve what you want:
<asp:button id="Button1" runat="server" text="Click me" onclick="Button1_Click" onclientclick="return Confirmation();" xmlns:asp="#unknown" />
function Confirmation() {
if (confirm("OK for next confirm")) {
if (confirm("OK for postback event")) {
return true;
}
}
return false;
}
如果有帮助请告诉我。
Azee ......
Let me know if it helps.
Azee...
请参考
http://www.aspsnippets.com/Articles/Calling-server-side-function-from-JavaScript-in-ASP.Net.aspx [ ^ ]
您可以使用JavaScript确认框
您需要在按钮的OnClientClick事件上添加确认框。当用户响应第一个确认框时然后抓住第一个确认框的结果.pop up第二次确认根据响应。
保存隐藏字段中的第二个确认框值并使用它来执行代码中的C#函数
假设你有一个隐藏名称hdnconfirm
在你身边r aspx文件
You can use JavaScript confirm box
You need to add confirm box on OnClientClick event of button .when a user response to first confirm box then catch the result of first confirm box .pop up second confirm according to response .
save second confirm box values in hidden field and use that to execute your C# function in code behind
suppose you have one hiddenfield name hdnconfirm
In your aspx file
<asp:Button ID="btnInvoke" runat="server" Text="Click"
onclick="btnInvoke_Click" OnClientClick="return confirmation();" />
<asp:HiddenField ID = "hdnconfirm" runat="server" Visible="true" />
你的asp页头部分的
in head section of your asp page
<script type="text/javascript" language="javascript">
function confirmation() {
var FirstConfirmResult = confirm("Click yes to proceed else Cancel");
if (FirstConfirmResult == true)
{
var SecondConfirmResult = confirm("This is second confirm box ");
if (SecondConfirmResult == true )
{
document.getElementById('hdnconfirm').value = "Yes";
}
else
{
document.getElementById('hdnconfirm').value = "No";
}
}
}
</script>
在后面的代码中使用此hdnconfirm.value来执行您的功能
Use this hdnconfirm.value in code behind to execute your function
protected void btnInvoke_Click(object sender, EventArgs e)
{
if (hdnconfirm.value == "Yes")
{
Do some processing here
}
}
希望这就是你所需要的!
Hope This is what you need !
这篇关于2单击asp.net中的按钮时的确认消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!