Confirm message box in asp.net

Posted by Aparna Bhise under ASP.NET on 6/22/2011 | Points: 10 | Views : 105639 | Status : [Member] | Replies : 4
I have code like this

protected void Button1_Click(object sender, EventArgs e)
{
bool IsValidated = ValidateFunction();
If(IsValidated == true)
{
Here I have to display the confirmation message to the user.

if (user clicks on "OK" button)
{
//Do something here
}
else //if user click on "Cancel" button
{
//Do something else
}

}

}

Thanks and Regards,

Aparna Bhise



Responses

Posted by: Naimishforu on: 6/22/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
if (MessageBox.Show("Validated?","Validate", MessageBoxButtons.YesNo ) == DialogResult.Yes )

{
// A 'DialogResult.Yes' value was returned from the MessageBox
}


Thanks,
Naimish
http://dotnetinterview.zxq.net/
http://naimishpandya.blogspot.in/

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

Posted by: Naimishforu on: 6/22/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
In Your Code :

protected void Button1_Click(object sender, EventArgs e) 

{
bool IsValidated = ValidateFunction();
If(IsValidated == true)
{

if (MessageBox.Show("Validated?","Validate", MessageBoxButtons.YesNo ) == DialogResult.Yes )
{
//Do something here
}
else //if user click on "Cancel" button
{
//Do something else
}

}

}


Thanks,
Naimish
http://dotnetinterview.zxq.net/
http://naimishpandya.blogspot.in/

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

Posted by: Seenuvasan on: 6/22/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

Try this

var result=confirm(" confirmation message here");

if(result==true)
{
//pressed ok button
}
else
{
//pressed cancel button
}


Thanks,
Seen

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

Posted by: Karthikanbarasan on: 6/22/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Hi,

Check these links to get some clear idea

http://www.4guysfromrolla.com/articles/021104-1.aspx
http://forums.asp.net/t/1385869.aspx/1?Confirm+Message+Box+with+OK+or+Cancel+option+in+C+


Thanks
Karthik
www.f5Debug.net

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

Login to post response