confirm message box--in code behind

Posted by Sugi under C# on 12/1/2012 | Points: 10 | Views : 49469 | Status : [Member] | Replies : 11
how to show confirm mesage yes/no on button click using C# in code behind.




Responses

Posted by: Gow.Net on: 12/2/2012 [Member] Starter | Points: 25

Up
0
Down
try this

 private void button1_Click(object sender, EventArgs e)

{
DialogResult Result = MessageBox.Show("Are You Sure", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

switch (Result)
{
case DialogResult.Yes:
MessageBox.Show("You Clik Yes", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

break;
case DialogResult.No:
MessageBox.Show("You Clik NO", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
break;



}

 Download source file

gowthaman8870226416

Sugi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kevin2012 on: 12/2/2012 [Member] Starter | Points: 25

Up
0
Down
How to do this kind of erioror message in web application ?
I need to show application level error in Popup box ? can you help ?


Sugi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gow.Net on: 12/3/2012 [Member] Starter | Points: 25

Up
0
Down
try this in asp.net
<span onclick="return confirm('Are you sure to Share to Selected Friends?')">

<asp:Button ID="btn_bost" runat="server" Text="Post" />
</span>

or
<script  type="text/javascript">

function askConfirm() {
if (confirm("are you sure")) {
alert("Clicked Yes");
}
else {
alert("Clicked No");
return false;
}
}
</script>

<asp:Button ID="KeygenButton" runat="server" Height="138px"   Width="176px" onclientclick="return askConfirm()" />


gowthaman8870226416

Sugi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gow.Net on: 12/3/2012 [Member] Starter | Points: 25

Up
0
Down
in asp.net
<script  type="text/javascript">


function askConfirm() {

if (confirm("are you sure")) {

alert("Clicked Yes");

}

else {

alert("Clicked No");

return false;

}

}

</script>

<asp:Button ID="KeygenButton" runat="server" Height="138px" Width="176px" onclientclick="return askConfirm()" />


gowthaman8870226416

Sugi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gow.Net on: 12/3/2012 [Member] Starter | Points: 25

Up
0
Down
refer This link
http://madskristensen.net/post/JavaScript-AlertShow(e2809dmessagee2809d)-from-ASPNET-code-behind.aspx

gowthaman8870226416

Sugi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: perfectchourasia-9163 on: 12/10/2012 [Member] Starter | Points: 25

Up
0
Down
http://sandeep-chourasia.blogspot.in/2011/08/type-of-message.html

ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/

Sugi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: perfectchourasia-9163 on: 12/10/2012 [Member] Starter | Points: 25

Up
0
Down
http://sandeep-chourasia.blogspot.in/2011/08/type-of-message.html

ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/

Sugi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ermahesh2009 on: 1/17/2013 [Member] Starter | Points: 25

Up
0
Down
use this link with demo

http://codeasp.net/blogs/raghav_khunger/microsoft-net/777/asp-net-how-to-open-confirm-box-from-codebehind-or-server-side

Sugi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ankitsrist on: 1/17/2013 [Member] Starter | Points: 25

Up
0
Down
bool result=confirm("are u sure");
if(result==yes)
{
responser.redirect("default.aspx");
}
else
{
response.redirect("logout.aspx");
}

Sugi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ankitsrist on: 1/17/2013 [Member] Starter | Points: 25

Up
0
Down
try that

Sugi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ankitsrist on: 1/17/2013 [Member] Starter | Points: 25

Up
0
Down
or simply write onClientClick=confirm("are u sure want to move")

Sugi, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response