pop up confirmation help me please

Discussion in 'ASP .Net' started by graphicsxp, May 26, 2006.

  1. graphicsxp

    graphicsxp Guest

    Hi,
    I have a function in my code-behind (vb.net) that checks if the file
    the user is trying to upload already exists on the server. At that
    point I'd like to display a pop up saying 'Are you sure you want to
    overwrite the existing file?'. If the user clilcks yes, the function
    carries on.

    How can I do that? How can I display a javascript popup at that point
    of the execution and get the value returned by that popup ?

    I'm really struggling on this :(

    Thank you
     
    graphicsxp, May 26, 2006
    #1
    1. Advertising

  2. graphicsxp

    Hans Kesting Guest

    > Hi,
    > I have a function in my code-behind (vb.net) that checks if the file
    > the user is trying to upload already exists on the server. At that
    > point I'd like to display a pop up saying 'Are you sure you want to
    > overwrite the existing file?'. If the user clilcks yes, the function
    > carries on.
    >
    > How can I do that? How can I display a javascript popup at that point
    > of the execution and get the value returned by that popup ?
    >
    > I'm really struggling on this :(
    >
    > Thank you


    You can't (as you found out) just show a popup in the middle of
    server-side code.

    You will need to remember the file server side, redirect to a "are you
    sure" page and either remove the stored copy or overwrite the existing
    file based on the reaction there (you might also consider giving a new
    name).

    Server side copy: either a temporary file (but: you will want to
    provide some mechanism to delete old copies - as when you never
    received an answer to the "are you sure" page), or a Byte[] in Session
    (but: this might be big!)

    Hans Kesting
     
    Hans Kesting, May 26, 2006
    #2
    1. Advertising

  3. Write the file to a temporary file on your server, then send back your
    response asking them if they wish to overwrite. If they do just delete the
    old and move the new.

    --
    Regards

    John Timney
    Microsoft MVP

    "graphicsxp" <> wrote in message
    news:...
    > Hi,
    > I have a function in my code-behind (vb.net) that checks if the file
    > the user is trying to upload already exists on the server. At that
    > point I'd like to display a pop up saying 'Are you sure you want to
    > overwrite the existing file?'. If the user clilcks yes, the function
    > carries on.
    >
    > How can I do that? How can I display a javascript popup at that point
    > of the execution and get the value returned by that popup ?
    >
    > I'm really struggling on this :(
    >
    > Thank you
    >
     
    John Timney \( MVP \), May 26, 2006
    #3
  4. graphicsxp

    Mark Rae Guest

    "graphicsxp" <> wrote in message
    news:...

    > How can I do that? How can I display a javascript popup at that point
    > of the execution and get the value returned by that popup ?
    >
    > I'm really struggling on this :(


    http://psacake.com/web/iw.asp
     
    Mark Rae, May 26, 2006
    #4
  5. graphicsxp

    Mark Rae Guest

    "graphicsxp" <> wrote in message
    news:...

    Sorry - ignore my earlier reply - didn't read your OP properly.

    Go with Hans' suggestion...
     
    Mark Rae, May 26, 2006
    #5
  6. graphicsxp

    graphicsxp Guest

    But yet I was told it is possible to do it in javascript using hidden
    fields and stuff like that... have you heard of this ?
     
    graphicsxp, May 26, 2006
    #6
  7. graphicsxp

    Mark Rae Guest

    "graphicsxp" <> wrote in message
    news:...

    > But yet I was told it is possible to do it in javascript using hidden
    > fields and stuff like that... have you heard of this ?


    Think about it:

    JavaScript runs client-side i.e. on the user's machine.

    How can it possibly know whether a file exists on the remote (web)server or
    not...?
     
    Mark Rae, May 26, 2006
    #7
  8. graphicsxp

    graphicsxp Guest

    no i was not talking about that. you obviously detect that in the code
    behind. But then there should be a way to do a postback and display a
    javascript confirmbox, get the answer, and do appropriate action
    (upload or not the file)
     
    graphicsxp, May 26, 2006
    #8
  9. graphicsxp

    Mark Rae Guest

    "graphicsxp" <> wrote in message
    news:...

    > no i was not talking about that. you obviously detect that in the code
    > behind. But then there should be a way to do a postback and display a
    > javascript confirmbox, get the answer, and do appropriate action
    > (upload or not the file)


    Of course, and that's what's been suggested - you just can't do it all in
    one single postback... :)
     
    Mark Rae, May 26, 2006
    #9
  10. not to muddy the waters...but wouldn't Ajax work for this scenario? , but of
    course that has its own issues

    Jose
    "graphicsxp" <> wrote in message
    news:...
    > But yet I was told it is possible to do it in javascript using hidden
    > fields and stuff like that... have you heard of this ?
    >
     
    Jose Rodriguez, May 26, 2006
    #10
  11. graphicsxp

    skaufmann

    Joined:
    May 13, 2009
    Messages:
    1
    I noticed this post while browsing. Yes I real I am about 3 years late, but what I think graphicsxp was looking for is something like this:


    Dim strMessage As String = "Are you sure you want to overwrite the file?"

    'finishes server processing, returns to client.
    Dim strScript As String = "<script language=JavaScript>"
    strScript += "confirm(""" & strMessage & """);"
    strScript += "</script>"

    Page.ClientScript.RegisterStartupScript(Page.GetType(), "clientScript", strScript)
     
    skaufmann, May 13, 2009
    #11
    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. Michal A. Valasek

    Re: Server Side Confirmation pop-up...

    Michal A. Valasek, Jul 25, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    607
    Michal A. Valasek
    Jul 25, 2003
  2. S. Justin Gengo

    Re: Server Side Confirmation pop-up...

    S. Justin Gengo, Jul 25, 2003, in forum: ASP .Net
    Replies:
    9
    Views:
    547
    Daniel Bass
    Jul 28, 2003
  3. Amelyan
    Replies:
    1
    Views:
    8,426
    Steve C. Orr [MVP, MCSD]
    Apr 29, 2005
  4. Elton W
    Replies:
    0
    Views:
    3,319
    Elton W
    May 15, 2005
  5. Samy
    Replies:
    5
    Views:
    720
Loading...

Share This Page