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

Discussion in 'ASP .Net' started by =?Utf-8?B?TWlrZSBNb29yZQ==?=, Oct 18, 2004.

  1. 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.
     
    =?Utf-8?B?TWlrZSBNb29yZQ==?=, Oct 18, 2004
    #1
    1. Advertising

  2. 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:...
    > 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.
     
    Steve C. Orr [MVP, MCSD], Oct 19, 2004
    #2
    1. Advertising

  3. 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:...
    > > 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.
     
    matteo cunietti, Oct 19, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Grey
    Replies:
    1
    Views:
    636
    Eliyahu Goldin
    May 11, 2004
  2. JenHu
    Replies:
    3
    Views:
    12,677
    Saravana
    Nov 30, 2004
  3. teo
    Replies:
    3
    Views:
    569
  4. Jimmy Tran
    Replies:
    1
    Views:
    254
    Dan Brussee
    Oct 3, 2003
  5. Jamie Herre
    Replies:
    1
    Views:
    226
    why the lucky stiff
    Jan 7, 2005
Loading...

Share This Page