p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 2.0 Professional (http://p2p.wrox.com/forumdisplay.php?f=215)
-   -   message box (http://p2p.wrox.com/showthread.php?t=36333)

nalla December 21st, 2005 07:36 AM

message box
 

Hi,

I have added an attribute to a button in page load as,

this.btnHome.Attributes.Add("onclick","if(!confirm ('Are you sure to delete this Event?')) return false;");

and this shows the message box properly with 2 options "Ok" and "Cancel". so i added a condition inside the button's click event as,

if(!confirm('Are you sure to delete this Event?'))
   {

   }
else
   {

   }
but this shows 2 syntax errors as,
(1) The name confirn doesnot exist in the class or namespace ....
(2) Too many characters in the character literal.

how can i return whether user pressed "Ok" or "Cancel"??

nalla



sky_handsome December 22nd, 2005 03:11 AM

hi, i have tried to put the if-else statement in a javascript function, then associate this function with OnClick event, then that code works correctly!!


nalla December 22nd, 2005 04:35 AM



Hi,

I need to do it in my C# code. but anyway it's fine if it's working in java code. can explain bit more how did you do it and post the code?

nalla



sky_handsome December 22nd, 2005 09:23 PM

<script type="text/javascript">
function doConfirm()
{
    if(!Confirm('ffds'))
    {}
     else
     {}
}
</script>

i put the above code in the aspx file. then i write the following code in c#.
this.Button1.Attributes.Add("OnClick","doConfirm() ");

you can try this. it works well on my machine.


nalla December 23rd, 2005 03:00 AM



Hi,

Thanx.I'll try that.

nalla





All times are GMT -4. The time now is 03:28 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.