Re: Server Side Confirmation pop-up...

Discussion in 'ASP .Net' started by S. Justin Gengo, Jul 25, 2003.

  1. Dan,

    You're just thinking about it too hard! :)

    Try this:

    WebControlButton.Attributes.Add("onClick", "javascript:if(!confirm('Do you
    wish to complete this order?')) return false;")

    Now if the confirmation goes through the WebControlButton's click event
    server side will be fired and your server side code can all go there.

    If the confirmation's cancel button is clicked note that the javascript
    function returns false. The form will not be posted back in that case.

    Is this what you want?


    --
    S. Justin Gengo, MCP
    Web Developer

    Free code library at:
    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzche
    "Daniel Bass" <> wrote in message
    news:...
    > I know I know, you can't have a server side pop up, even if you could it
    > would pop up on the servers monitor and not the client...
    >
    > but what i want to do is, when a button is clicked on a screen, launched

    the
    > confirm("...") message box, then call server side code on the code behind
    > page, depending on the result of the confirm box.
    >
    > I've got something like this at the moment:
    >
    > >>>> myPage.aspx.vb

    > ----------------------------
    > Public Class myClass
    > Inherits System.Web.UI.Page
    >
    > '...... other initialization stuff
    >
    > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles MyBase.Load
    > 'Put user code to initialize the page here
    >
    > If Not IsPostBack Then
    >
    > '.... someother code
    > btnRelease.Attributes.Add("onclick", "OnRelease();")
    >
    > End If
    >
    > End Sub
    >
    > Public Sub btnComplete_ServerClick()
    > ' ....my server side ADO.net code
    > End Sub
    >
    > '......... etc etc
    > End Class
    >
    >
    > >>>>> myPage.asp

    > -----------------------
    >
    > <!-- my head title tags and all that joy... -->
    >
    > function OnComplete()
    > {
    > if ( confirm("Do you wish to complete this order?") )
    > {
    > btnComplete_ServerClick()
    > }
    > }
    >
    > <!-- my body tags and rest of the code and all that joy -->
    >
    > <<<<<<<<<<<<<<<<<, the end
    >
    >
    >
    > now it's obvious this ain't gonna work, even with my wishful thinking,
    > because there's no object btnComplete_ServerClick when the script

    function
    > is called...
    >
    > so how do you do it?!?!?
    >
    > thanks.
    > Dan.
    >
    >
     
    S. Justin Gengo, Jul 25, 2003
    #1
    1. Advertising

  2. S. Justin Gengo

    Daniel Bass Guest

    You can do that?? You da man!

    Only I'm getting and object doesn't exist error on this block in the HTML,
    the highlight in question sort of starts at the "a" in false and goes
    through to the "d" in __doPostBack... so I'm not sure which one it's
    complaining about.

    onclick="javascript:if(!confirm('Do you wish to complete this order?')) {
    return false; } __doPostBack('btnComplete','')"

    Thanks.

    Dan.



    "S. Justin Gengo" <> wrote in message
    news:%...
    > Dan,
    >
    > You're just thinking about it too hard! :)
    >
    > Try this:
    >
    > WebControlButton.Attributes.Add("onClick", "javascript:if(!confirm('Do you
    > wish to complete this order?')) return false;")
    >
    > Now if the confirmation goes through the WebControlButton's click event
    > server side will be fired and your server side code can all go there.
    >
    > If the confirmation's cancel button is clicked note that the javascript
    > function returns false. The form will not be posted back in that case.
    >
    > Is this what you want?
    >
    >
    > --
    > S. Justin Gengo, MCP
    > Web Developer
    >
    > Free code library at:
    > www.aboutfortunate.com
    >
    > "Out of chaos comes order."
    > Nietzche
    > "Daniel Bass" <> wrote in message
    > news:...
    > > I know I know, you can't have a server side pop up, even if you could it
    > > would pop up on the servers monitor and not the client...
    > >
    > > but what i want to do is, when a button is clicked on a screen, launched

    > the
    > > confirm("...") message box, then call server side code on the code

    behind
    > > page, depending on the result of the confirm box.
    > >
    > > I've got something like this at the moment:
    > >
    > > >>>> myPage.aspx.vb

    > > ----------------------------
    > > Public Class myClass
    > > Inherits System.Web.UI.Page
    > >
    > > '...... other initialization stuff
    > >
    > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > > System.EventArgs) Handles MyBase.Load
    > > 'Put user code to initialize the page here
    > >
    > > If Not IsPostBack Then
    > >
    > > '.... someother code
    > > btnRelease.Attributes.Add("onclick", "OnRelease();")
    > >
    > > End If
    > >
    > > End Sub
    > >
    > > Public Sub btnComplete_ServerClick()
    > > ' ....my server side ADO.net code
    > > End Sub
    > >
    > > '......... etc etc
    > > End Class
    > >
    > >
    > > >>>>> myPage.asp

    > > -----------------------
    > >
    > > <!-- my head title tags and all that joy... -->
    > >
    > > function OnComplete()
    > > {
    > > if ( confirm("Do you wish to complete this order?") )
    > > {
    > > btnComplete_ServerClick()
    > > }
    > > }
    > >
    > > <!-- my body tags and rest of the code and all that joy -->
    > >
    > > <<<<<<<<<<<<<<<<<, the end
    > >
    > >
    > >
    > > now it's obvious this ain't gonna work, even with my wishful thinking,
    > > because there's no object btnComplete_ServerClick when the script

    > function
    > > is called...
    > >
    > > so how do you do it?!?!?
    > >
    > > thanks.
    > > Dan.
    > >
    > >

    >
    >
     
    Daniel Bass, Jul 25, 2003
    #2
    1. Advertising

  3. Dan,

    Did you add the do post back stuff yourself?

    I run the code I gave you in my codebehind page's page load and it's
    produced in the html sent to the client like this:

    <input type="submit" name="Button1" value="Button" id="Button1"
    onClick="javascript:if(!confirm('Do you wish to complete this order?'))
    return false;" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 8px"
    />

    Where is the doPostBack routine of yours coming from?

    --
    S. Justin Gengo, MCP
    Web Developer

    Free code library at:
    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzche
    "Daniel Bass" <> wrote in message
    news:...
    > You can do that?? You da man!
    >
    > Only I'm getting and object doesn't exist error on this block in the HTML,
    > the highlight in question sort of starts at the "a" in false and goes
    > through to the "d" in __doPostBack... so I'm not sure which one it's
    > complaining about.
    >
    > onclick="javascript:if(!confirm('Do you wish to complete this order?')) {
    > return false; } __doPostBack('btnComplete','')"
    >
    > Thanks.
    >
    > Dan.
    >
    >
    >
    > "S. Justin Gengo" <> wrote in message
    > news:%...
    > > Dan,
    > >
    > > You're just thinking about it too hard! :)
    > >
    > > Try this:
    > >
    > > WebControlButton.Attributes.Add("onClick", "javascript:if(!confirm('Do

    you
    > > wish to complete this order?')) return false;")
    > >
    > > Now if the confirmation goes through the WebControlButton's click event
    > > server side will be fired and your server side code can all go there.
    > >
    > > If the confirmation's cancel button is clicked note that the javascript
    > > function returns false. The form will not be posted back in that case.
    > >
    > > Is this what you want?
    > >
    > >
    > > --
    > > S. Justin Gengo, MCP
    > > Web Developer
    > >
    > > Free code library at:
    > > www.aboutfortunate.com
    > >
    > > "Out of chaos comes order."
    > > Nietzche
    > > "Daniel Bass" <> wrote in message
    > > news:...
    > > > I know I know, you can't have a server side pop up, even if you could

    it
    > > > would pop up on the servers monitor and not the client...
    > > >
    > > > but what i want to do is, when a button is clicked on a screen,

    launched
    > > the
    > > > confirm("...") message box, then call server side code on the code

    > behind
    > > > page, depending on the result of the confirm box.
    > > >
    > > > I've got something like this at the moment:
    > > >
    > > > >>>> myPage.aspx.vb
    > > > ----------------------------
    > > > Public Class myClass
    > > > Inherits System.Web.UI.Page
    > > >
    > > > '...... other initialization stuff
    > > >
    > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > > > System.EventArgs) Handles MyBase.Load
    > > > 'Put user code to initialize the page here
    > > >
    > > > If Not IsPostBack Then
    > > >
    > > > '.... someother code
    > > > btnRelease.Attributes.Add("onclick", "OnRelease();")
    > > >
    > > > End If
    > > >
    > > > End Sub
    > > >
    > > > Public Sub btnComplete_ServerClick()
    > > > ' ....my server side ADO.net code
    > > > End Sub
    > > >
    > > > '......... etc etc
    > > > End Class
    > > >
    > > >
    > > > >>>>> myPage.asp
    > > > -----------------------
    > > >
    > > > <!-- my head title tags and all that joy... -->
    > > >
    > > > function OnComplete()
    > > > {
    > > > if ( confirm("Do you wish to complete this order?") )
    > > > {
    > > > btnComplete_ServerClick()
    > > > }
    > > > }
    > > >
    > > > <!-- my body tags and rest of the code and all that joy -->
    > > >
    > > > <<<<<<<<<<<<<<<<<, the end
    > > >
    > > >
    > > >
    > > > now it's obvious this ain't gonna work, even with my wishful thinking,
    > > > because there's no object btnComplete_ServerClick when the script

    > > function
    > > > is called...
    > > >
    > > > so how do you do it?!?!?
    > > >
    > > > thanks.
    > > > Dan.
    > > >
    > > >

    > >
    > >

    >
    >
     
    S. Justin Gengo, Jul 25, 2003
    #3
  4. As long as you're using a asp.net button then that button is associated with
    a server side event.

    It would look like this:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles Button1.Click

    '---Put your code here

    End Sub


    --
    S. Justin Gengo, MCP
    Web Developer

    Free code library at:
    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzche
    "Daniel Bass" <> wrote in message
    news:...
    > What do i do when the users clicked on OK?
    >
    > What I'd like to happen is for some server side code to run and process a
    > few bits...
    >
    > The code you gave me, I thought I'd be able to do this?
    >
    > my bad.
    >
    > "S. Justin Gengo" <> wrote in message
    > news:%...
    > > Dan,
    > >
    > > Did you add the do post back stuff yourself?
    > >
    > > I run the code I gave you in my codebehind page's page load and it's
    > > produced in the html sent to the client like this:
    > >
    > > <input type="submit" name="Button1" value="Button" id="Button1"
    > > onClick="javascript:if(!confirm('Do you wish to complete this order?'))
    > > return false;" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP:

    > 8px"
    > > />
    > >
    > > Where is the doPostBack routine of yours coming from?
    > >
    > > --
    > > S. Justin Gengo, MCP
    > > Web Developer
    > >
    > > Free code library at:
    > > www.aboutfortunate.com
    > >
    > > "Out of chaos comes order."
    > > Nietzche
    > > "Daniel Bass" <> wrote in message
    > > news:...
    > > > You can do that?? You da man!
    > > >
    > > > Only I'm getting and object doesn't exist error on this block in the

    > HTML,
    > > > the highlight in question sort of starts at the "a" in false and goes
    > > > through to the "d" in __doPostBack... so I'm not sure which one it's
    > > > complaining about.
    > > >
    > > > onclick="javascript:if(!confirm('Do you wish to complete this

    order?'))
    > {
    > > > return false; } __doPostBack('btnComplete','')"
    > > >
    > > > Thanks.
    > > >
    > > > Dan.
    > > >
    > > >
    > > >
    > > > "S. Justin Gengo" <> wrote in message
    > > > news:%...
    > > > > Dan,
    > > > >
    > > > > You're just thinking about it too hard! :)
    > > > >
    > > > > Try this:
    > > > >
    > > > > WebControlButton.Attributes.Add("onClick",

    "javascript:if(!confirm('Do
    > > you
    > > > > wish to complete this order?')) return false;")
    > > > >
    > > > > Now if the confirmation goes through the WebControlButton's click

    > event
    > > > > server side will be fired and your server side code can all go

    there.
    > > > >
    > > > > If the confirmation's cancel button is clicked note that the

    > javascript
    > > > > function returns false. The form will not be posted back in that

    case.
    > > > >
    > > > > Is this what you want?
    > > > >
    > > > >
    > > > > --
    > > > > S. Justin Gengo, MCP
    > > > > Web Developer
    > > > >
    > > > > Free code library at:
    > > > > www.aboutfortunate.com
    > > > >
    > > > > "Out of chaos comes order."
    > > > > Nietzche
    > > > > "Daniel Bass" <> wrote in

    message
    > > > > news:...
    > > > > > I know I know, you can't have a server side pop up, even if you

    > could
    > > it
    > > > > > would pop up on the servers monitor and not the client...
    > > > > >
    > > > > > but what i want to do is, when a button is clicked on a screen,

    > > launched
    > > > > the
    > > > > > confirm("...") message box, then call server side code on the code
    > > > behind
    > > > > > page, depending on the result of the confirm box.
    > > > > >
    > > > > > I've got something like this at the moment:
    > > > > >
    > > > > > >>>> myPage.aspx.vb
    > > > > > ----------------------------
    > > > > > Public Class myClass
    > > > > > Inherits System.Web.UI.Page
    > > > > >
    > > > > > '...... other initialization stuff
    > > > > >
    > > > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e

    As
    > > > > > System.EventArgs) Handles MyBase.Load
    > > > > > 'Put user code to initialize the page here
    > > > > >
    > > > > > If Not IsPostBack Then
    > > > > >
    > > > > > '.... someother code
    > > > > > btnRelease.Attributes.Add("onclick", "OnRelease();")
    > > > > >
    > > > > > End If
    > > > > >
    > > > > > End Sub
    > > > > >
    > > > > > Public Sub btnComplete_ServerClick()
    > > > > > ' ....my server side ADO.net code
    > > > > > End Sub
    > > > > >
    > > > > > '......... etc etc
    > > > > > End Class
    > > > > >
    > > > > >
    > > > > > >>>>> myPage.asp
    > > > > > -----------------------
    > > > > >
    > > > > > <!-- my head title tags and all that joy... -->
    > > > > >
    > > > > > function OnComplete()
    > > > > > {
    > > > > > if ( confirm("Do you wish to complete this order?") )
    > > > > > {
    > > > > > btnComplete_ServerClick()
    > > > > > }
    > > > > > }
    > > > > >
    > > > > > <!-- my body tags and rest of the code and all that joy -->
    > > > > >
    > > > > > <<<<<<<<<<<<<<<<<, the end
    > > > > >
    > > > > >
    > > > > >
    > > > > > now it's obvious this ain't gonna work, even with my wishful

    > thinking,
    > > > > > because there's no object btnComplete_ServerClick when the script
    > > > > function
    > > > > > is called...
    > > > > >
    > > > > > so how do you do it?!?!?
    > > > > >
    > > > > > thanks.
    > > > > > Dan.
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    S. Justin Gengo, Jul 25, 2003
    #4
  5. S. Justin Gengo

    Daniel Bass Guest

    I've got an confirmation box, which will have to be launched client side.
    I then need some server side code to be launched if there is a "yes" click
    on the confirmation screen...

    is this possible?

    you either have a server side event handler, or a onClick event handler in
    the client... this is what's causing me the problem.


    "S. Justin Gengo" <> wrote in message
    news:...
    > As long as you're using a asp.net button then that button is associated

    with
    > a server side event.
    >
    > It would look like this:
    >
    > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles Button1.Click
    >
    > '---Put your code here
    >
    > End Sub
    >
    >
    > --
    > S. Justin Gengo, MCP
    > Web Developer
    >
    > Free code library at:
    > www.aboutfortunate.com
    >
    > "Out of chaos comes order."
    > Nietzche
    > "Daniel Bass" <> wrote in message
    > news:...
    > > What do i do when the users clicked on OK?
    > >
    > > What I'd like to happen is for some server side code to run and process

    a
    > > few bits...
    > >
    > > The code you gave me, I thought I'd be able to do this?
    > >
    > > my bad.
    > >
    > > "S. Justin Gengo" <> wrote in message
    > > news:%...
    > > > Dan,
    > > >
    > > > Did you add the do post back stuff yourself?
    > > >
    > > > I run the code I gave you in my codebehind page's page load and it's
    > > > produced in the html sent to the client like this:
    > > >
    > > > <input type="submit" name="Button1" value="Button" id="Button1"
    > > > onClick="javascript:if(!confirm('Do you wish to complete this

    order?'))
    > > > return false;" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute;

    TOP:
    > > 8px"
    > > > />
    > > >
    > > > Where is the doPostBack routine of yours coming from?
    > > >
    > > > --
    > > > S. Justin Gengo, MCP
    > > > Web Developer
    > > >
    > > > Free code library at:
    > > > www.aboutfortunate.com
    > > >
    > > > "Out of chaos comes order."
    > > > Nietzche
    > > > "Daniel Bass" <> wrote in message
    > > > news:...
    > > > > You can do that?? You da man!
    > > > >
    > > > > Only I'm getting and object doesn't exist error on this block in the

    > > HTML,
    > > > > the highlight in question sort of starts at the "a" in false and

    goes
    > > > > through to the "d" in __doPostBack... so I'm not sure which one it's
    > > > > complaining about.
    > > > >
    > > > > onclick="javascript:if(!confirm('Do you wish to complete this

    > order?'))
    > > {
    > > > > return false; } __doPostBack('btnComplete','')"
    > > > >
    > > > > Thanks.
    > > > >
    > > > > Dan.
    > > > >
    > > > >
    > > > >
    > > > > "S. Justin Gengo" <> wrote in message
    > > > > news:%...
    > > > > > Dan,
    > > > > >
    > > > > > You're just thinking about it too hard! :)
    > > > > >
    > > > > > Try this:
    > > > > >
    > > > > > WebControlButton.Attributes.Add("onClick",

    > "javascript:if(!confirm('Do
    > > > you
    > > > > > wish to complete this order?')) return false;")
    > > > > >
    > > > > > Now if the confirmation goes through the WebControlButton's click

    > > event
    > > > > > server side will be fired and your server side code can all go

    > there.
    > > > > >
    > > > > > If the confirmation's cancel button is clicked note that the

    > > javascript
    > > > > > function returns false. The form will not be posted back in that

    > case.
    > > > > >
    > > > > > Is this what you want?
    > > > > >
    > > > > >
    > > > > > --
    > > > > > S. Justin Gengo, MCP
    > > > > > Web Developer
    > > > > >
    > > > > > Free code library at:
    > > > > > www.aboutfortunate.com
    > > > > >
    > > > > > "Out of chaos comes order."
    > > > > > Nietzche
    > > > > > "Daniel Bass" <> wrote in

    > message
    > > > > > news:...
    > > > > > > I know I know, you can't have a server side pop up, even if you

    > > could
    > > > it
    > > > > > > would pop up on the servers monitor and not the client...
    > > > > > >
    > > > > > > but what i want to do is, when a button is clicked on a screen,
    > > > launched
    > > > > > the
    > > > > > > confirm("...") message box, then call server side code on the

    code
    > > > > behind
    > > > > > > page, depending on the result of the confirm box.
    > > > > > >
    > > > > > > I've got something like this at the moment:
    > > > > > >
    > > > > > > >>>> myPage.aspx.vb
    > > > > > > ----------------------------
    > > > > > > Public Class myClass
    > > > > > > Inherits System.Web.UI.Page
    > > > > > >
    > > > > > > '...... other initialization stuff
    > > > > > >
    > > > > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e

    > As
    > > > > > > System.EventArgs) Handles MyBase.Load
    > > > > > > 'Put user code to initialize the page here
    > > > > > >
    > > > > > > If Not IsPostBack Then
    > > > > > >
    > > > > > > '.... someother code
    > > > > > > btnRelease.Attributes.Add("onclick", "OnRelease();")
    > > > > > >
    > > > > > > End If
    > > > > > >
    > > > > > > End Sub
    > > > > > >
    > > > > > > Public Sub btnComplete_ServerClick()
    > > > > > > ' ....my server side ADO.net code
    > > > > > > End Sub
    > > > > > >
    > > > > > > '......... etc etc
    > > > > > > End Class
    > > > > > >
    > > > > > >
    > > > > > > >>>>> myPage.asp
    > > > > > > -----------------------
    > > > > > >
    > > > > > > <!-- my head title tags and all that joy... -->
    > > > > > >
    > > > > > > function OnComplete()
    > > > > > > {
    > > > > > > if ( confirm("Do you wish to complete this order?") )
    > > > > > > {
    > > > > > > btnComplete_ServerClick()
    > > > > > > }
    > > > > > > }
    > > > > > >
    > > > > > > <!-- my body tags and rest of the code and all that joy -->
    > > > > > >
    > > > > > > <<<<<<<<<<<<<<<<<, the end
    > > > > > >
    > > > > > >
    > > > > > >
    > > > > > > now it's obvious this ain't gonna work, even with my wishful

    > > thinking,
    > > > > > > because there's no object btnComplete_ServerClick when the

    script
    > > > > > function
    > > > > > > is called...
    > > > > > >
    > > > > > > so how do you do it?!?!?
    > > > > > >
    > > > > > > thanks.
    > > > > > > Dan.
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    Daniel Bass, Jul 28, 2003
    #5
  6. S. Justin Gengo

    Daniel Bass Guest

    the post back stuff is a result of me adding a server side handler for the
    button...
    if i don't have an event handler, then how can i get a server side method to
    run after this client side event?

    "S. Justin Gengo" <> wrote in message
    news:%...
    > Dan,
    >
    > Did you add the do post back stuff yourself?
    >
    > I run the code I gave you in my codebehind page's page load and it's
    > produced in the html sent to the client like this:
    >
    > <input type="submit" name="Button1" value="Button" id="Button1"
    > onClick="javascript:if(!confirm('Do you wish to complete this order?'))
    > return false;" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP:

    8px"
    > />
    >
    > Where is the doPostBack routine of yours coming from?
    >
    > --
    > S. Justin Gengo, MCP
    > Web Developer
    >
    > Free code library at:
    > www.aboutfortunate.com
    >
    > "Out of chaos comes order."
    > Nietzche
    > "Daniel Bass" <> wrote in message
    > news:...
    > > You can do that?? You da man!
    > >
    > > Only I'm getting and object doesn't exist error on this block in the

    HTML,
    > > the highlight in question sort of starts at the "a" in false and goes
    > > through to the "d" in __doPostBack... so I'm not sure which one it's
    > > complaining about.
    > >
    > > onclick="javascript:if(!confirm('Do you wish to complete this order?'))

    {
    > > return false; } __doPostBack('btnComplete','')"
    > >
    > > Thanks.
    > >
    > > Dan.
    > >
    > >
    > >
    > > "S. Justin Gengo" <> wrote in message
    > > news:%...
    > > > Dan,
    > > >
    > > > You're just thinking about it too hard! :)
    > > >
    > > > Try this:
    > > >
    > > > WebControlButton.Attributes.Add("onClick", "javascript:if(!confirm('Do

    > you
    > > > wish to complete this order?')) return false;")
    > > >
    > > > Now if the confirmation goes through the WebControlButton's click

    event
    > > > server side will be fired and your server side code can all go there.
    > > >
    > > > If the confirmation's cancel button is clicked note that the

    javascript
    > > > function returns false. The form will not be posted back in that case.
    > > >
    > > > Is this what you want?
    > > >
    > > >
    > > > --
    > > > S. Justin Gengo, MCP
    > > > Web Developer
    > > >
    > > > Free code library at:
    > > > www.aboutfortunate.com
    > > >
    > > > "Out of chaos comes order."
    > > > Nietzche
    > > > "Daniel Bass" <> wrote in message
    > > > news:...
    > > > > I know I know, you can't have a server side pop up, even if you

    could
    > it
    > > > > would pop up on the servers monitor and not the client...
    > > > >
    > > > > but what i want to do is, when a button is clicked on a screen,

    > launched
    > > > the
    > > > > confirm("...") message box, then call server side code on the code

    > > behind
    > > > > page, depending on the result of the confirm box.
    > > > >
    > > > > I've got something like this at the moment:
    > > > >
    > > > > >>>> myPage.aspx.vb
    > > > > ----------------------------
    > > > > Public Class myClass
    > > > > Inherits System.Web.UI.Page
    > > > >
    > > > > '...... other initialization stuff
    > > > >
    > > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > > > > System.EventArgs) Handles MyBase.Load
    > > > > 'Put user code to initialize the page here
    > > > >
    > > > > If Not IsPostBack Then
    > > > >
    > > > > '.... someother code
    > > > > btnRelease.Attributes.Add("onclick", "OnRelease();")
    > > > >
    > > > > End If
    > > > >
    > > > > End Sub
    > > > >
    > > > > Public Sub btnComplete_ServerClick()
    > > > > ' ....my server side ADO.net code
    > > > > End Sub
    > > > >
    > > > > '......... etc etc
    > > > > End Class
    > > > >
    > > > >
    > > > > >>>>> myPage.asp
    > > > > -----------------------
    > > > >
    > > > > <!-- my head title tags and all that joy... -->
    > > > >
    > > > > function OnComplete()
    > > > > {
    > > > > if ( confirm("Do you wish to complete this order?") )
    > > > > {
    > > > > btnComplete_ServerClick()
    > > > > }
    > > > > }
    > > > >
    > > > > <!-- my body tags and rest of the code and all that joy -->
    > > > >
    > > > > <<<<<<<<<<<<<<<<<, the end
    > > > >
    > > > >
    > > > >
    > > > > now it's obvious this ain't gonna work, even with my wishful

    thinking,
    > > > > because there's no object btnComplete_ServerClick when the script
    > > > function
    > > > > is called...
    > > > >
    > > > > so how do you do it?!?!?
    > > > >
    > > > > thanks.
    > > > > Dan.
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    Daniel Bass, Jul 28, 2003
    #6
  7. You'll have to add an event handler.

    --
    S. Justin Gengo, MCP
    Web Developer

    Free code library at:
    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzche
    "Daniel Bass" <> wrote in message
    news:...
    > the post back stuff is a result of me adding a server side handler for the
    > button...
    > if i don't have an event handler, then how can i get a server side method

    to
    > run after this client side event?
    >
    > "S. Justin Gengo" <> wrote in message
    > news:%...
    > > Dan,
    > >
    > > Did you add the do post back stuff yourself?
    > >
    > > I run the code I gave you in my codebehind page's page load and it's
    > > produced in the html sent to the client like this:
    > >
    > > <input type="submit" name="Button1" value="Button" id="Button1"
    > > onClick="javascript:if(!confirm('Do you wish to complete this order?'))
    > > return false;" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP:

    > 8px"
    > > />
    > >
    > > Where is the doPostBack routine of yours coming from?
    > >
    > > --
    > > S. Justin Gengo, MCP
    > > Web Developer
    > >
    > > Free code library at:
    > > www.aboutfortunate.com
    > >
    > > "Out of chaos comes order."
    > > Nietzche
    > > "Daniel Bass" <> wrote in message
    > > news:...
    > > > You can do that?? You da man!
    > > >
    > > > Only I'm getting and object doesn't exist error on this block in the

    > HTML,
    > > > the highlight in question sort of starts at the "a" in false and goes
    > > > through to the "d" in __doPostBack... so I'm not sure which one it's
    > > > complaining about.
    > > >
    > > > onclick="javascript:if(!confirm('Do you wish to complete this

    order?'))
    > {
    > > > return false; } __doPostBack('btnComplete','')"
    > > >
    > > > Thanks.
    > > >
    > > > Dan.
    > > >
    > > >
    > > >
    > > > "S. Justin Gengo" <> wrote in message
    > > > news:%...
    > > > > Dan,
    > > > >
    > > > > You're just thinking about it too hard! :)
    > > > >
    > > > > Try this:
    > > > >
    > > > > WebControlButton.Attributes.Add("onClick",

    "javascript:if(!confirm('Do
    > > you
    > > > > wish to complete this order?')) return false;")
    > > > >
    > > > > Now if the confirmation goes through the WebControlButton's click

    > event
    > > > > server side will be fired and your server side code can all go

    there.
    > > > >
    > > > > If the confirmation's cancel button is clicked note that the

    > javascript
    > > > > function returns false. The form will not be posted back in that

    case.
    > > > >
    > > > > Is this what you want?
    > > > >
    > > > >
    > > > > --
    > > > > S. Justin Gengo, MCP
    > > > > Web Developer
    > > > >
    > > > > Free code library at:
    > > > > www.aboutfortunate.com
    > > > >
    > > > > "Out of chaos comes order."
    > > > > Nietzche
    > > > > "Daniel Bass" <> wrote in

    message
    > > > > news:...
    > > > > > I know I know, you can't have a server side pop up, even if you

    > could
    > > it
    > > > > > would pop up on the servers monitor and not the client...
    > > > > >
    > > > > > but what i want to do is, when a button is clicked on a screen,

    > > launched
    > > > > the
    > > > > > confirm("...") message box, then call server side code on the code
    > > > behind
    > > > > > page, depending on the result of the confirm box.
    > > > > >
    > > > > > I've got something like this at the moment:
    > > > > >
    > > > > > >>>> myPage.aspx.vb
    > > > > > ----------------------------
    > > > > > Public Class myClass
    > > > > > Inherits System.Web.UI.Page
    > > > > >
    > > > > > '...... other initialization stuff
    > > > > >
    > > > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e

    As
    > > > > > System.EventArgs) Handles MyBase.Load
    > > > > > 'Put user code to initialize the page here
    > > > > >
    > > > > > If Not IsPostBack Then
    > > > > >
    > > > > > '.... someother code
    > > > > > btnRelease.Attributes.Add("onclick", "OnRelease();")
    > > > > >
    > > > > > End If
    > > > > >
    > > > > > End Sub
    > > > > >
    > > > > > Public Sub btnComplete_ServerClick()
    > > > > > ' ....my server side ADO.net code
    > > > > > End Sub
    > > > > >
    > > > > > '......... etc etc
    > > > > > End Class
    > > > > >
    > > > > >
    > > > > > >>>>> myPage.asp
    > > > > > -----------------------
    > > > > >
    > > > > > <!-- my head title tags and all that joy... -->
    > > > > >
    > > > > > function OnComplete()
    > > > > > {
    > > > > > if ( confirm("Do you wish to complete this order?") )
    > > > > > {
    > > > > > btnComplete_ServerClick()
    > > > > > }
    > > > > > }
    > > > > >
    > > > > > <!-- my body tags and rest of the code and all that joy -->
    > > > > >
    > > > > > <<<<<<<<<<<<<<<<<, the end
    > > > > >
    > > > > >
    > > > > >
    > > > > > now it's obvious this ain't gonna work, even with my wishful

    > thinking,
    > > > > > because there's no object btnComplete_ServerClick when the script
    > > > > function
    > > > > > is called...
    > > > > >
    > > > > > so how do you do it?!?!?
    > > > > >
    > > > > > thanks.
    > > > > > Dan.
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    S. Justin Gengo, Jul 28, 2003
    #7
  8. S. Justin Gengo

    Daniel Bass Guest

    Thanks for your patience, you must think i'm thick!!!

    to clarify... I add

    WebControlButton.Attributes.Add("onClick",
    "javascript:if(!confirm('Do you wish to complete this order?')) return
    false;")

    to the Page_Load method...
    I also double click on the button then, to write my server side stuff,
    getting this :-

    Public Sub WebControlButton_ServerClick(ByVal obj As Object, ByVal e
    As System.EventArgs) Handles btnRelease.ServerClick

    ...some server side stuff

    End Sub


    so this then executes the javascript, then if the user clicks okay,
    processes my WebControlButton_ServerClick method?

    but i get an object doesn't exist error when i do this,
    onclick="javascript:if(!confirm('Do you wish to complete this
    order?')) { return false; } __doPostBack('btnComplete','')"

    on the doPostBack which the compiler adds when the page is processed.





    "S. Justin Gengo" <> wrote in message
    news:...
    > Daniel,
    >
    > The code I gave you attaches a javascript confirmation to a specific

    button.
    > When that button is clicked the form will only be posted back to the

    server
    > if a user clicks "OK". Once the form is submitted you place the code you
    > want to run inside of that buttons click event which occurrs server side.
    >
    > --
    > S. Justin Gengo, MCP
    > Web Developer
    >
    > Free code library at:
    > www.aboutfortunate.com
    >
    > "Out of chaos comes order."
    > Nietzche
    > "Daniel Bass" <> wrote in message
    > news:...
    > > I've got an confirmation box, which will have to be launched client

    side.
    > > I then need some server side code to be launched if there is a "yes"

    click
    > > on the confirmation screen...
    > >
    > > is this possible?
    > >
    > > you either have a server side event handler, or a onClick event handler

    in
    > > the client... this is what's causing me the problem.
    > >
    > >
    > > "S. Justin Gengo" <> wrote in message
    > > news:...
    > > > As long as you're using a asp.net button then that button is

    associated
    > > with
    > > > a server side event.
    > > >
    > > > It would look like this:
    > > >
    > > > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
    > > > System.EventArgs) Handles Button1.Click
    > > >
    > > > '---Put your code here
    > > >
    > > > End Sub
    > > >
    > > >
    > > > --
    > > > S. Justin Gengo, MCP
    > > > Web Developer
    > > >
    > > > Free code library at:
    > > > www.aboutfortunate.com
    > > >
    > > > "Out of chaos comes order."
    > > > Nietzche
    > > > "Daniel Bass" <> wrote in message
    > > > news:...
    > > > > What do i do when the users clicked on OK?
    > > > >
    > > > > What I'd like to happen is for some server side code to run and

    > process
    > > a
    > > > > few bits...
    > > > >
    > > > > The code you gave me, I thought I'd be able to do this?
    > > > >
    > > > > my bad.
    > > > >
    > > > > "S. Justin Gengo" <> wrote in message
    > > > > news:%...
    > > > > > Dan,
    > > > > >
    > > > > > Did you add the do post back stuff yourself?
    > > > > >
    > > > > > I run the code I gave you in my codebehind page's page load and

    it's
    > > > > > produced in the html sent to the client like this:
    > > > > >
    > > > > > <input type="submit" name="Button1" value="Button" id="Button1"
    > > > > > onClick="javascript:if(!confirm('Do you wish to complete this

    > > order?'))
    > > > > > return false;" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute;

    > > TOP:
    > > > > 8px"
    > > > > > />
    > > > > >
    > > > > > Where is the doPostBack routine of yours coming from?
    > > > > >
    > > > > > --
    > > > > > S. Justin Gengo, MCP
    > > > > > Web Developer
    > > > > >
    > > > > > Free code library at:
    > > > > > www.aboutfortunate.com
    > > > > >
    > > > > > "Out of chaos comes order."
    > > > > > Nietzche
    > > > > > "Daniel Bass" <> wrote in

    > message
    > > > > > news:...
    > > > > > > You can do that?? You da man!
    > > > > > >
    > > > > > > Only I'm getting and object doesn't exist error on this block in

    > the
    > > > > HTML,
    > > > > > > the highlight in question sort of starts at the "a" in false and

    > > goes
    > > > > > > through to the "d" in __doPostBack... so I'm not sure which one

    > it's
    > > > > > > complaining about.
    > > > > > >
    > > > > > > onclick="javascript:if(!confirm('Do you wish to complete this
    > > > order?'))
    > > > > {
    > > > > > > return false; } __doPostBack('btnComplete','')"
    > > > > > >
    > > > > > > Thanks.
    > > > > > >
    > > > > > > Dan.
    > > > > > >
    > > > > > >
    > > > > > >
    > > > > > > "S. Justin Gengo" <> wrote in message
    > > > > > > news:%...
    > > > > > > > Dan,
    > > > > > > >
    > > > > > > > You're just thinking about it too hard! :)
    > > > > > > >
    > > > > > > > Try this:
    > > > > > > >
    > > > > > > > WebControlButton.Attributes.Add("onClick",
    > > > "javascript:if(!confirm('Do
    > > > > > you
    > > > > > > > wish to complete this order?')) return false;")
    > > > > > > >
    > > > > > > > Now if the confirmation goes through the WebControlButton's

    > click
    > > > > event
    > > > > > > > server side will be fired and your server side code can all go
    > > > there.
    > > > > > > >
    > > > > > > > If the confirmation's cancel button is clicked note that the
    > > > > javascript
    > > > > > > > function returns false. The form will not be posted back in

    that
    > > > case.
    > > > > > > >
    > > > > > > > Is this what you want?
    > > > > > > >
    > > > > > > >
    > > > > > > > --
    > > > > > > > S. Justin Gengo, MCP
    > > > > > > > Web Developer
    > > > > > > >
    > > > > > > > Free code library at:
    > > > > > > > www.aboutfortunate.com
    > > > > > > >
    > > > > > > > "Out of chaos comes order."
    > > > > > > > Nietzche
    > > > > > > > "Daniel Bass" <> wrote in
    > > > message
    > > > > > > > news:...
    > > > > > > > > I know I know, you can't have a server side pop up, even if

    > you
    > > > > could
    > > > > > it
    > > > > > > > > would pop up on the servers monitor and not the client...
    > > > > > > > >
    > > > > > > > > but what i want to do is, when a button is clicked on a

    > screen,
    > > > > > launched
    > > > > > > > the
    > > > > > > > > confirm("...") message box, then call server side code on

    the
    > > code
    > > > > > > behind
    > > > > > > > > page, depending on the result of the confirm box.
    > > > > > > > >
    > > > > > > > > I've got something like this at the moment:
    > > > > > > > >
    > > > > > > > > >>>> myPage.aspx.vb
    > > > > > > > > ----------------------------
    > > > > > > > > Public Class myClass
    > > > > > > > > Inherits System.Web.UI.Page
    > > > > > > > >
    > > > > > > > > '...... other initialization stuff
    > > > > > > > >
    > > > > > > > > Private Sub Page_Load(ByVal sender As System.Object,

    ByVal
    > e
    > > > As
    > > > > > > > > System.EventArgs) Handles MyBase.Load
    > > > > > > > > 'Put user code to initialize the page here
    > > > > > > > >
    > > > > > > > > If Not IsPostBack Then
    > > > > > > > >
    > > > > > > > > '.... someother code
    > > > > > > > > btnRelease.Attributes.Add("onclick",

    > "OnRelease();")
    > > > > > > > >
    > > > > > > > > End If
    > > > > > > > >
    > > > > > > > > End Sub
    > > > > > > > >
    > > > > > > > > Public Sub btnComplete_ServerClick()
    > > > > > > > > ' ....my server side ADO.net code
    > > > > > > > > End Sub
    > > > > > > > >
    > > > > > > > > '......... etc etc
    > > > > > > > > End Class
    > > > > > > > >
    > > > > > > > >
    > > > > > > > > >>>>> myPage.asp
    > > > > > > > > -----------------------
    > > > > > > > >
    > > > > > > > > <!-- my head title tags and all that joy... -->
    > > > > > > > >
    > > > > > > > > function OnComplete()
    > > > > > > > > {
    > > > > > > > > if ( confirm("Do you wish to complete this

    order?") )
    > > > > > > > > {
    > > > > > > > > btnComplete_ServerClick()
    > > > > > > > > }
    > > > > > > > > }
    > > > > > > > >
    > > > > > > > > <!-- my body tags and rest of the code and all that joy -->
    > > > > > > > >
    > > > > > > > > <<<<<<<<<<<<<<<<<, the end
    > > > > > > > >
    > > > > > > > >
    > > > > > > > >
    > > > > > > > > now it's obvious this ain't gonna work, even with my wishful
    > > > > thinking,
    > > > > > > > > because there's no object btnComplete_ServerClick when the

    > > script
    > > > > > > > function
    > > > > > > > > is called...
    > > > > > > > >
    > > > > > > > > so how do you do it?!?!?
    > > > > > > > >
    > > > > > > > > thanks.
    > > > > > > > > Dan.
    > > > > > > > >
    > > > > > > > >
    > > > > > > >
    > > > > > > >
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    Daniel Bass, Jul 28, 2003
    #8
  9. It took me quite a while to get the hang of this so, no, I don't think your
    thick! :)

    When I use this code there is no __DoPostBack

    I notice that the __DoPostBack is trying to fire a different button,
    btnComplete...

    Does this button exist? If not that is the cause of the object doesn't exist
    error.

    If it does exist try attaching the confirmation to the btnComplete Button
    instead:

    btnComplete.Attributes.Add("onClick", "javascript:if(!confirm('Do you wish
    to complete this order?')) return false;")

    --
    S. Justin Gengo, MCP
    Web Developer

    Free code library at:
    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzche
    "Daniel Bass" <> wrote in message
    news:...
    > Thanks for your patience, you must think i'm thick!!!
    >
    > to clarify... I add
    >
    > WebControlButton.Attributes.Add("onClick",
    > "javascript:if(!confirm('Do you wish to complete this order?')) return
    > false;")
    >
    > to the Page_Load method...
    > I also double click on the button then, to write my server side stuff,
    > getting this :-
    >
    > Public Sub WebControlButton_ServerClick(ByVal obj As Object, ByVal

    e
    > As System.EventArgs) Handles btnRelease.ServerClick
    >
    > ...some server side stuff
    >
    > End Sub
    >
    >
    > so this then executes the javascript, then if the user clicks okay,
    > processes my WebControlButton_ServerClick method?
    >
    > but i get an object doesn't exist error when i do this,
    > onclick="javascript:if(!confirm('Do you wish to complete this
    > order?')) { return false; } __doPostBack('btnComplete','')"
    >
    > on the doPostBack which the compiler adds when the page is processed.
    >
    >
    >
    >
    >
    > "S. Justin Gengo" <> wrote in message
    > news:...
    > > Daniel,
    > >
    > > The code I gave you attaches a javascript confirmation to a specific

    > button.
    > > When that button is clicked the form will only be posted back to the

    > server
    > > if a user clicks "OK". Once the form is submitted you place the code you
    > > want to run inside of that buttons click event which occurrs server

    side.
    > >
    > > --
    > > S. Justin Gengo, MCP
    > > Web Developer
    > >
    > > Free code library at:
    > > www.aboutfortunate.com
    > >
    > > "Out of chaos comes order."
    > > Nietzche
    > > "Daniel Bass" <> wrote in message
    > > news:...
    > > > I've got an confirmation box, which will have to be launched client

    > side.
    > > > I then need some server side code to be launched if there is a "yes"

    > click
    > > > on the confirmation screen...
    > > >
    > > > is this possible?
    > > >
    > > > you either have a server side event handler, or a onClick event

    handler
    > in
    > > > the client... this is what's causing me the problem.
    > > >
    > > >
    > > > "S. Justin Gengo" <> wrote in message
    > > > news:...
    > > > > As long as you're using a asp.net button then that button is

    > associated
    > > > with
    > > > > a server side event.
    > > > >
    > > > > It would look like this:
    > > > >
    > > > > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
    > > > > System.EventArgs) Handles Button1.Click
    > > > >
    > > > > '---Put your code here
    > > > >
    > > > > End Sub
    > > > >
    > > > >
    > > > > --
    > > > > S. Justin Gengo, MCP
    > > > > Web Developer
    > > > >
    > > > > Free code library at:
    > > > > www.aboutfortunate.com
    > > > >
    > > > > "Out of chaos comes order."
    > > > > Nietzche
    > > > > "Daniel Bass" <> wrote in

    message
    > > > > news:...
    > > > > > What do i do when the users clicked on OK?
    > > > > >
    > > > > > What I'd like to happen is for some server side code to run and

    > > process
    > > > a
    > > > > > few bits...
    > > > > >
    > > > > > The code you gave me, I thought I'd be able to do this?
    > > > > >
    > > > > > my bad.
    > > > > >
    > > > > > "S. Justin Gengo" <> wrote in message
    > > > > > news:%...
    > > > > > > Dan,
    > > > > > >
    > > > > > > Did you add the do post back stuff yourself?
    > > > > > >
    > > > > > > I run the code I gave you in my codebehind page's page load and

    > it's
    > > > > > > produced in the html sent to the client like this:
    > > > > > >
    > > > > > > <input type="submit" name="Button1" value="Button" id="Button1"
    > > > > > > onClick="javascript:if(!confirm('Do you wish to complete this
    > > > order?'))
    > > > > > > return false;" style="Z-INDEX: 101; LEFT: 8px; POSITION:

    absolute;
    > > > TOP:
    > > > > > 8px"
    > > > > > > />
    > > > > > >
    > > > > > > Where is the doPostBack routine of yours coming from?
    > > > > > >
    > > > > > > --
    > > > > > > S. Justin Gengo, MCP
    > > > > > > Web Developer
    > > > > > >
    > > > > > > Free code library at:
    > > > > > > www.aboutfortunate.com
    > > > > > >
    > > > > > > "Out of chaos comes order."
    > > > > > > Nietzche
    > > > > > > "Daniel Bass" <> wrote in

    > > message
    > > > > > > news:...
    > > > > > > > You can do that?? You da man!
    > > > > > > >
    > > > > > > > Only I'm getting and object doesn't exist error on this block

    in
    > > the
    > > > > > HTML,
    > > > > > > > the highlight in question sort of starts at the "a" in false

    and
    > > > goes
    > > > > > > > through to the "d" in __doPostBack... so I'm not sure which

    one
    > > it's
    > > > > > > > complaining about.
    > > > > > > >
    > > > > > > > onclick="javascript:if(!confirm('Do you wish to complete this
    > > > > order?'))
    > > > > > {
    > > > > > > > return false; } __doPostBack('btnComplete','')"
    > > > > > > >
    > > > > > > > Thanks.
    > > > > > > >
    > > > > > > > Dan.
    > > > > > > >
    > > > > > > >
    > > > > > > >
    > > > > > > > "S. Justin Gengo" <> wrote in

    message
    > > > > > > > news:%...
    > > > > > > > > Dan,
    > > > > > > > >
    > > > > > > > > You're just thinking about it too hard! :)
    > > > > > > > >
    > > > > > > > > Try this:
    > > > > > > > >
    > > > > > > > > WebControlButton.Attributes.Add("onClick",
    > > > > "javascript:if(!confirm('Do
    > > > > > > you
    > > > > > > > > wish to complete this order?')) return false;")
    > > > > > > > >
    > > > > > > > > Now if the confirmation goes through the WebControlButton's

    > > click
    > > > > > event
    > > > > > > > > server side will be fired and your server side code can all

    go
    > > > > there.
    > > > > > > > >
    > > > > > > > > If the confirmation's cancel button is clicked note that the
    > > > > > javascript
    > > > > > > > > function returns false. The form will not be posted back in

    > that
    > > > > case.
    > > > > > > > >
    > > > > > > > > Is this what you want?
    > > > > > > > >
    > > > > > > > >
    > > > > > > > > --
    > > > > > > > > S. Justin Gengo, MCP
    > > > > > > > > Web Developer
    > > > > > > > >
    > > > > > > > > Free code library at:
    > > > > > > > > www.aboutfortunate.com
    > > > > > > > >
    > > > > > > > > "Out of chaos comes order."
    > > > > > > > > Nietzche
    > > > > > > > > "Daniel Bass" <> wrote

    in
    > > > > message
    > > > > > > > > news:...
    > > > > > > > > > I know I know, you can't have a server side pop up, even

    if
    > > you
    > > > > > could
    > > > > > > it
    > > > > > > > > > would pop up on the servers monitor and not the client...
    > > > > > > > > >
    > > > > > > > > > but what i want to do is, when a button is clicked on a

    > > screen,
    > > > > > > launched
    > > > > > > > > the
    > > > > > > > > > confirm("...") message box, then call server side code on

    > the
    > > > code
    > > > > > > > behind
    > > > > > > > > > page, depending on the result of the confirm box.
    > > > > > > > > >
    > > > > > > > > > I've got something like this at the moment:
    > > > > > > > > >
    > > > > > > > > > >>>> myPage.aspx.vb
    > > > > > > > > > ----------------------------
    > > > > > > > > > Public Class myClass
    > > > > > > > > > Inherits System.Web.UI.Page
    > > > > > > > > >
    > > > > > > > > > '...... other initialization stuff
    > > > > > > > > >
    > > > > > > > > > Private Sub Page_Load(ByVal sender As System.Object,

    > ByVal
    > > e
    > > > > As
    > > > > > > > > > System.EventArgs) Handles MyBase.Load
    > > > > > > > > > 'Put user code to initialize the page here
    > > > > > > > > >
    > > > > > > > > > If Not IsPostBack Then
    > > > > > > > > >
    > > > > > > > > > '.... someother code
    > > > > > > > > > btnRelease.Attributes.Add("onclick",

    > > "OnRelease();")
    > > > > > > > > >
    > > > > > > > > > End If
    > > > > > > > > >
    > > > > > > > > > End Sub
    > > > > > > > > >
    > > > > > > > > > Public Sub btnComplete_ServerClick()
    > > > > > > > > > ' ....my server side ADO.net code
    > > > > > > > > > End Sub
    > > > > > > > > >
    > > > > > > > > > '......... etc etc
    > > > > > > > > > End Class
    > > > > > > > > >
    > > > > > > > > >
    > > > > > > > > > >>>>> myPage.asp
    > > > > > > > > > -----------------------
    > > > > > > > > >
    > > > > > > > > > <!-- my head title tags and all that joy... -->
    > > > > > > > > >
    > > > > > > > > > function OnComplete()
    > > > > > > > > > {
    > > > > > > > > > if ( confirm("Do you wish to complete this

    > order?") )
    > > > > > > > > > {
    > > > > > > > > > btnComplete_ServerClick()
    > > > > > > > > > }
    > > > > > > > > > }
    > > > > > > > > >
    > > > > > > > > > <!-- my body tags and rest of the code and all that

    joy -->
    > > > > > > > > >
    > > > > > > > > > <<<<<<<<<<<<<<<<<, the end
    > > > > > > > > >
    > > > > > > > > >
    > > > > > > > > >
    > > > > > > > > > now it's obvious this ain't gonna work, even with my

    wishful
    > > > > > thinking,
    > > > > > > > > > because there's no object btnComplete_ServerClick when

    the
    > > > script
    > > > > > > > > function
    > > > > > > > > > is called...
    > > > > > > > > >
    > > > > > > > > > so how do you do it?!?!?
    > > > > > > > > >
    > > > > > > > > > thanks.
    > > > > > > > > > Dan.
    > > > > > > > > >
    > > > > > > > > >
    > > > > > > > >
    > > > > > > > >
    > > > > > > >
    > > > > > > >
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    S. Justin Gengo, Jul 28, 2003
    #9
  10. S. Justin Gengo

    Daniel Bass Guest

    the html for the button in question is:

    <INPUT id=btnComplete type=button value=Complete name=btnComplete
    RUNAT="server">

    the aspx.vb Page_Load code is this:

    btnComplete.Attributes.Add("onclick", "javascript:if(!confirm('Do you
    wish to complete this order?')) return false;")

    the event handler looks like this:

    Private Sub btnComplete_ServerClick(ByVal sender As System.Object,
    ByVal e As System.EventArgs) Handles btnComplete.ServerClick
    Dim i = 0 ' break point here so i know it executes
    End Sub


    but i get this error...

    <input language="javascript" onclick="javascript:if(!confirm('Do you
    wish to complete this order?')) return false;
    __doPostBack('btnComplete','')" name="btnComplete" id="btnComplete"
    type="button" value="Complete" />



    the stupid thing is that btnComplete is only defined after it's used as a
    parameter in the postback method... how in the earth did that happen? You'll
    notice the HTML for my declaration puts the ID right at the front.

    Hmm... we get closer to the solution though.

    Thanks again.


    "S. Justin Gengo" <> wrote in message
    news:%23dqR9%...
    > It took me quite a while to get the hang of this so, no, I don't think

    your
    > thick! :)
    >
    > When I use this code there is no __DoPostBack
    >
    > I notice that the __DoPostBack is trying to fire a different button,
    > btnComplete...
    >
    > Does this button exist? If not that is the cause of the object doesn't

    exist
    > error.
    >
    > If it does exist try attaching the confirmation to the btnComplete Button
    > instead:
    >
    > btnComplete.Attributes.Add("onClick", "javascript:if(!confirm('Do you wish
    > to complete this order?')) return false;")
    >
    > --
    > S. Justin Gengo, MCP
    > Web Developer
    >
    > Free code library at:
    > www.aboutfortunate.com
    >
    > "Out of chaos comes order."
    > Nietzche
    > "Daniel Bass" <> wrote in message
    > news:...
    > > Thanks for your patience, you must think i'm thick!!!
    > >
    > > to clarify... I add
    > >
    > > WebControlButton.Attributes.Add("onClick",
    > > "javascript:if(!confirm('Do you wish to complete this order?')) return
    > > false;")
    > >
    > > to the Page_Load method...
    > > I also double click on the button then, to write my server side stuff,
    > > getting this :-
    > >
    > > Public Sub WebControlButton_ServerClick(ByVal obj As Object,

    ByVal
    > e
    > > As System.EventArgs) Handles btnRelease.ServerClick
    > >
    > > ...some server side stuff
    > >
    > > End Sub
    > >
    > >
    > > so this then executes the javascript, then if the user clicks okay,
    > > processes my WebControlButton_ServerClick method?
    > >
    > > but i get an object doesn't exist error when i do this,
    > > onclick="javascript:if(!confirm('Do you wish to complete this
    > > order?')) { return false; } __doPostBack('btnComplete','')"
    > >
    > > on the doPostBack which the compiler adds when the page is processed.
    > >
    > >
    > >
    > >
    > >
    > > "S. Justin Gengo" <> wrote in message
    > > news:...
    > > > Daniel,
    > > >
    > > > The code I gave you attaches a javascript confirmation to a specific

    > > button.
    > > > When that button is clicked the form will only be posted back to the

    > > server
    > > > if a user clicks "OK". Once the form is submitted you place the code

    you
    > > > want to run inside of that buttons click event which occurrs server

    > side.
    > > >
    > > > --
    > > > S. Justin Gengo, MCP
    > > > Web Developer
    > > >
    > > > Free code library at:
    > > > www.aboutfortunate.com
    > > >
    > > > "Out of chaos comes order."
    > > > Nietzche
    > > > "Daniel Bass" <> wrote in message
    > > > news:...
    > > > > I've got an confirmation box, which will have to be launched client

    > > side.
    > > > > I then need some server side code to be launched if there is a "yes"

    > > click
    > > > > on the confirmation screen...
    > > > >
    > > > > is this possible?
    > > > >
    > > > > you either have a server side event handler, or a onClick event

    > handler
    > > in
    > > > > the client... this is what's causing me the problem.
    > > > >
    > > > >
    > > > > "S. Justin Gengo" <> wrote in message
    > > > > news:...
    > > > > > As long as you're using a asp.net button then that button is

    > > associated
    > > > > with
    > > > > > a server side event.
    > > > > >
    > > > > > It would look like this:
    > > > > >
    > > > > > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e

    As
    > > > > > System.EventArgs) Handles Button1.Click
    > > > > >
    > > > > > '---Put your code here
    > > > > >
    > > > > > End Sub
    > > > > >
    > > > > >
    > > > > > --
    > > > > > S. Justin Gengo, MCP
    > > > > > Web Developer
    > > > > >
    > > > > > Free code library at:
    > > > > > www.aboutfortunate.com
    > > > > >
    > > > > > "Out of chaos comes order."
    > > > > > Nietzche
    > > > > > "Daniel Bass" <> wrote in

    > message
    > > > > > news:...
    > > > > > > What do i do when the users clicked on OK?
    > > > > > >
    > > > > > > What I'd like to happen is for some server side code to run and
    > > > process
    > > > > a
    > > > > > > few bits...
    > > > > > >
    > > > > > > The code you gave me, I thought I'd be able to do this?
    > > > > > >
    > > > > > > my bad.
    > > > > > >
    > > > > > > "S. Justin Gengo" <> wrote in message
    > > > > > > news:%...
    > > > > > > > Dan,
    > > > > > > >
    > > > > > > > Did you add the do post back stuff yourself?
    > > > > > > >
    > > > > > > > I run the code I gave you in my codebehind page's page load

    and
    > > it's
    > > > > > > > produced in the html sent to the client like this:
    > > > > > > >
    > > > > > > > <input type="submit" name="Button1" value="Button"

    id="Button1"
    > > > > > > > onClick="javascript:if(!confirm('Do you wish to complete this
    > > > > order?'))
    > > > > > > > return false;" style="Z-INDEX: 101; LEFT: 8px; POSITION:

    > absolute;
    > > > > TOP:
    > > > > > > 8px"
    > > > > > > > />
    > > > > > > >
    > > > > > > > Where is the doPostBack routine of yours coming from?
    > > > > > > >
    > > > > > > > --
    > > > > > > > S. Justin Gengo, MCP
    > > > > > > > Web Developer
    > > > > > > >
    > > > > > > > Free code library at:
    > > > > > > > www.aboutfortunate.com
    > > > > > > >
    > > > > > > > "Out of chaos comes order."
    > > > > > > > Nietzche
    > > > > > > > "Daniel Bass" <> wrote in
    > > > message
    > > > > > > > news:...
    > > > > > > > > You can do that?? You da man!
    > > > > > > > >
    > > > > > > > > Only I'm getting and object doesn't exist error on this

    block
    > in
    > > > the
    > > > > > > HTML,
    > > > > > > > > the highlight in question sort of starts at the "a" in false

    > and
    > > > > goes
    > > > > > > > > through to the "d" in __doPostBack... so I'm not sure which

    > one
    > > > it's
    > > > > > > > > complaining about.
    > > > > > > > >
    > > > > > > > > onclick="javascript:if(!confirm('Do you wish to complete

    this
    > > > > > order?'))
    > > > > > > {
    > > > > > > > > return false; } __doPostBack('btnComplete','')"
    > > > > > > > >
    > > > > > > > > Thanks.
    > > > > > > > >
    > > > > > > > > Dan.
    > > > > > > > >
    > > > > > > > >
    > > > > > > > >
    > > > > > > > > "S. Justin Gengo" <> wrote in

    > message
    > > > > > > > > news:%...
    > > > > > > > > > Dan,
    > > > > > > > > >
    > > > > > > > > > You're just thinking about it too hard! :)
    > > > > > > > > >
    > > > > > > > > > Try this:
    > > > > > > > > >
    > > > > > > > > > WebControlButton.Attributes.Add("onClick",
    > > > > > "javascript:if(!confirm('Do
    > > > > > > > you
    > > > > > > > > > wish to complete this order?')) return false;")
    > > > > > > > > >
    > > > > > > > > > Now if the confirmation goes through the

    WebControlButton's
    > > > click
    > > > > > > event
    > > > > > > > > > server side will be fired and your server side code can

    all
    > go
    > > > > > there.
    > > > > > > > > >
    > > > > > > > > > If the confirmation's cancel button is clicked note that

    the
    > > > > > > javascript
    > > > > > > > > > function returns false. The form will not be posted back

    in
    > > that
    > > > > > case.
    > > > > > > > > >
    > > > > > > > > > Is this what you want?
    > > > > > > > > >
    > > > > > > > > >
    > > > > > > > > > --
    > > > > > > > > > S. Justin Gengo, MCP
    > > > > > > > > > Web Developer
    > > > > > > > > >
    > > > > > > > > > Free code library at:
    > > > > > > > > > www.aboutfortunate.com
    > > > > > > > > >
    > > > > > > > > > "Out of chaos comes order."
    > > > > > > > > > Nietzche
    > > > > > > > > > "Daniel Bass" <>

    wrote
    > in
    > > > > > message
    > > > > > > > > > news:...
    > > > > > > > > > > I know I know, you can't have a server side pop up, even

    > if
    > > > you
    > > > > > > could
    > > > > > > > it
    > > > > > > > > > > would pop up on the servers monitor and not the

    client...
    > > > > > > > > > >
    > > > > > > > > > > but what i want to do is, when a button is clicked on a
    > > > screen,
    > > > > > > > launched
    > > > > > > > > > the
    > > > > > > > > > > confirm("...") message box, then call server side code

    on
    > > the
    > > > > code
    > > > > > > > > behind
    > > > > > > > > > > page, depending on the result of the confirm box.
    > > > > > > > > > >
    > > > > > > > > > > I've got something like this at the moment:
    > > > > > > > > > >
    > > > > > > > > > > >>>> myPage.aspx.vb
    > > > > > > > > > > ----------------------------
    > > > > > > > > > > Public Class myClass
    > > > > > > > > > > Inherits System.Web.UI.Page
    > > > > > > > > > >
    > > > > > > > > > > '...... other initialization stuff
    > > > > > > > > > >
    > > > > > > > > > > Private Sub Page_Load(ByVal sender As System.Object,

    > > ByVal
    > > > e
    > > > > > As
    > > > > > > > > > > System.EventArgs) Handles MyBase.Load
    > > > > > > > > > > 'Put user code to initialize the page here
    > > > > > > > > > >
    > > > > > > > > > > If Not IsPostBack Then
    > > > > > > > > > >
    > > > > > > > > > > '.... someother code
    > > > > > > > > > > btnRelease.Attributes.Add("onclick",
    > > > "OnRelease();")
    > > > > > > > > > >
    > > > > > > > > > > End If
    > > > > > > > > > >
    > > > > > > > > > > End Sub
    > > > > > > > > > >
    > > > > > > > > > > Public Sub btnComplete_ServerClick()
    > > > > > > > > > > ' ....my server side ADO.net code
    > > > > > > > > > > End Sub
    > > > > > > > > > >
    > > > > > > > > > > '......... etc etc
    > > > > > > > > > > End Class
    > > > > > > > > > >
    > > > > > > > > > >
    > > > > > > > > > > >>>>> myPage.asp
    > > > > > > > > > > -----------------------
    > > > > > > > > > >
    > > > > > > > > > > <!-- my head title tags and all that joy... -->
    > > > > > > > > > >
    > > > > > > > > > > function OnComplete()
    > > > > > > > > > > {
    > > > > > > > > > > if ( confirm("Do you wish to complete this

    > > order?") )
    > > > > > > > > > > {
    > > > > > > > > > > btnComplete_ServerClick()
    > > > > > > > > > > }
    > > > > > > > > > > }
    > > > > > > > > > >
    > > > > > > > > > > <!-- my body tags and rest of the code and all that

    > joy -->
    > > > > > > > > > >
    > > > > > > > > > > <<<<<<<<<<<<<<<<<, the end
    > > > > > > > > > >
    > > > > > > > > > >
    > > > > > > > > > >
    > > > > > > > > > > now it's obvious this ain't gonna work, even with my

    > wishful
    > > > > > > thinking,
    > > > > > > > > > > because there's no object btnComplete_ServerClick when

    > the
    > > > > script
    > > > > > > > > > function
    > > > > > > > > > > is called...
    > > > > > > > > > >
    > > > > > > > > > > so how do you do it?!?!?
    > > > > > > > > > >
    > > > > > > > > > > thanks.
    > > > > > > > > > > Dan.
    > > > > > > > > > >
    > > > > > > > > > >
    > > > > > > > > >
    > > > > > > > > >
    > > > > > > > >
    > > > > > > > >
    > > > > > > >
    > > > > > > >
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    Daniel Bass, Jul 28, 2003
    #10
    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:
    597
    Michal A. Valasek
    Jul 25, 2003
  2. Amelyan
    Replies:
    1
    Views:
    8,348
    Steve C. Orr [MVP, MCSD]
    Apr 29, 2005
  3. Elton W
    Replies:
    0
    Views:
    3,295
    Elton W
    May 15, 2005
  4. Replies:
    2
    Views:
    8,534
    Randy Webb
    Feb 4, 2006
  5. Replies:
    2
    Views:
    144
    Randy Webb
    Feb 4, 2006
Loading...

Share This Page