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.