Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Message Box (delete record - Yes or No) - Help!

Reply
Thread Tools

Message Box (delete record - Yes or No) - Help!

 
 
=?Utf-8?B?TWlrZSBNb29yZQ==?=
Guest
Posts: n/a
 
      10-18-2004
asp.net app - How do you get Java-side code to communicate with server-side
code?
I have tried numerous ways and examples, but have been unsuccessful.

Therefore, unless I get real lucky and find another way of doing a messagebox,
none of the existing ways will work with the code we have already written.

Most all of the message box examples that I have found had the
message box code being executed behind a button, which
triggers a server event. This writes the javascript back
to the borwser and fires the box. Since the button click events
in the examples *don't have any server side code* in them this
works out quite well. The server does not execute any user code
so this gives the message box a chance to work with the
user and get redirected to another page.

My situation is different. I must have code behind buttons in the menu.
This is the code that sets certain session
variables to set up either an add, edit, or delete. In this case
this session code will always execute even if I bring
up a message box. In other words, I can't use the message box to
help me decide what code to run in the menu.

For this same reason I can't do a message box in the page_load
event of the grid page because the server will execute it's
code regardless of whether a message box is used or not. Because
of the way we did our menus using a template, I had to code most
of the logic in the page-load events to make our menus work and
avoid buttons below our grids. The message box and a delete works
independently, the record was deleted before the message box was displayed.

The only other type of messagebox I found was one that actually wrote
a hidden javascript field to the form and put either a 1 or 0 in it based on
the
user selecting a yes or no. This actually seemed like it might work,
but I have to reload the page, write the field, and then the asp.net
code can see if it is a zero or a 1. The problem is because they way we
are doing menus we have all the add,edit, and delte logic in the page load
events,
and this code executes before I can bring up the message box,
write the hidden field, reload the page to get the hidden field on the page,
and then test the value in the hidden field with asp.net code.
 
Reply With Quote
 
 
 
 
Steve C. Orr [MVP, MCSD]
Guest
Posts: n/a
 
      10-19-2004
Here's some server side code that outputs javascript similar to what you are
requesting:
myDeleteButton.Attributes.Add("onclick", _
"return confirm('Are you sure you want to delete?');")

In this example, the Delete button will post back only if the person
confirms they want to delete. Otherwise your server code is never called in
response to the button click.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net


"Mike Moore" <> wrote in message
news:E2FACBD9-1E3E-4565-B877-...
> asp.net app - How do you get Java-side code to communicate with
> server-side
> code?
> I have tried numerous ways and examples, but have been unsuccessful.
>
> Therefore, unless I get real lucky and find another way of doing a
> messagebox,
> none of the existing ways will work with the code we have already written.
>
> Most all of the message box examples that I have found had the
> message box code being executed behind a button, which
> triggers a server event. This writes the javascript back
> to the borwser and fires the box. Since the button click events
> in the examples *don't have any server side code* in them this
> works out quite well. The server does not execute any user code
> so this gives the message box a chance to work with the
> user and get redirected to another page.
>
> My situation is different. I must have code behind buttons in the menu.
> This is the code that sets certain session
> variables to set up either an add, edit, or delete. In this case
> this session code will always execute even if I bring
> up a message box. In other words, I can't use the message box to
> help me decide what code to run in the menu.
>
> For this same reason I can't do a message box in the page_load
> event of the grid page because the server will execute it's
> code regardless of whether a message box is used or not. Because
> of the way we did our menus using a template, I had to code most
> of the logic in the page-load events to make our menus work and
> avoid buttons below our grids. The message box and a delete works
> independently, the record was deleted before the message box was
> displayed.
>
> The only other type of messagebox I found was one that actually wrote
> a hidden javascript field to the form and put either a 1 or 0 in it based
> on
> the
> user selecting a yes or no. This actually seemed like it might work,
> but I have to reload the page, write the field, and then the asp.net
> code can see if it is a zero or a 1. The problem is because they way we
> are doing menus we have all the add,edit, and delte logic in the page load
> events,
> and this code executes before I can bring up the message box,
> write the hidden field, reload the page to get the hidden field on the
> page,
> and then test the value in the hidden field with asp.net code.



 
Reply With Quote
 
 
 
 
matteo cunietti
Guest
Posts: n/a
 
      10-19-2004
I had the same problem, I solved it this way :

button.Attributes.Add("onclick","event.returnValue = confirm('confirm?');");

this will work (not without event.returnvalue)
Teo



"Steve C. Orr [MVP, MCSD]" <> wrote in message news:<#>...
> Here's some server side code that outputs javascript similar to what you are
> requesting:
> myDeleteButton.Attributes.Add("onclick", _
> "return confirm('Are you sure you want to delete?');")
>
> In this example, the Delete button will post back only if the person
> confirms they want to delete. Otherwise your server code is never called in
> response to the button click.
>
> --
> I hope this helps,
> Steve C. Orr, MCSD, MVP
> http://Steve.Orr.net
>
>
> "Mike Moore" <> wrote in message
> news:E2FACBD9-1E3E-4565-B877-...
> > asp.net app - How do you get Java-side code to communicate with
> > server-side
> > code?
> > I have tried numerous ways and examples, but have been unsuccessful.
> >
> > Therefore, unless I get real lucky and find another way of doing a
> > messagebox,
> > none of the existing ways will work with the code we have already written.
> >
> > Most all of the message box examples that I have found had the
> > message box code being executed behind a button, which
> > triggers a server event. This writes the javascript back
> > to the borwser and fires the box. Since the button click events
> > in the examples *don't have any server side code* in them this
> > works out quite well. The server does not execute any user code
> > so this gives the message box a chance to work with the
> > user and get redirected to another page.
> >
> > My situation is different. I must have code behind buttons in the menu.
> > This is the code that sets certain session
> > variables to set up either an add, edit, or delete. In this case
> > this session code will always execute even if I bring
> > up a message box. In other words, I can't use the message box to
> > help me decide what code to run in the menu.
> >
> > For this same reason I can't do a message box in the page_load
> > event of the grid page because the server will execute it's
> > code regardless of whether a message box is used or not. Because
> > of the way we did our menus using a template, I had to code most
> > of the logic in the page-load events to make our menus work and
> > avoid buttons below our grids. The message box and a delete works
> > independently, the record was deleted before the message box was
> > displayed.
> >
> > The only other type of messagebox I found was one that actually wrote
> > a hidden javascript field to the form and put either a 1 or 0 in it based
> > on
> > the
> > user selecting a yes or no. This actually seemed like it might work,
> > but I have to reload the page, write the field, and then the asp.net
> > code can see if it is a zero or a 1. The problem is because they way we
> > are doing menus we have all the add,edit, and delte logic in the page load
> > events,
> > and this code executes before I can bring up the message box,
> > write the hidden field, reload the page to get the hidden field on the
> > page,
> > and then test the value in the hidden field with asp.net code.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Yes means yes Bucky Breeder Computer Support 0 05-19-2009 01:37 PM
yes minister and yes prime minister wanted music_mania DVD Video 11 12-11-2006 07:32 PM
[IE: Yes Opera:Yes Mozilla:No] : Error on Postback and Validation teo ASP .Net 3 11-11-2006 04:53 AM
Kernel.y and yes,yes,yes not least surprise Jamie Herre Ruby 1 01-07-2005 07:33 PM
yes yes Kevin Walsh Computer Support 1 08-30-2004 12:55 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57