Saturday, March 31, 2012

Server Side Confirmation pop-up...

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" <danielbassNOJUNK@dotnet.itags.org.MAILpostmaster.co.uk> wrote in message
news:urHxKGrUDHA.3972@dotnet.itags.org.tk2msftngp13.phx.gbl...
> 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.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" <sjgengo@.aboutfortunate.com> wrote in message
news:%23wpCmLrUDHA.2040@.TK2MSFTNGP11.phx.gbl...
> 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" <danielbassNOJUNK@.MAILpostmaster.co.uk> wrote in message
> news:urHxKGrUDHA.3972@.tk2msftngp13.phx.gbl...
> > 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.
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" <danielbassNOJUNK@.MAILpostmaster.co.uk> wrote in message
news:up8BTXrUDHA.2248@.TK2MSFTNGP10.phx.gbl...
> 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" <sjgengo@.aboutfortunate.com> wrote in message
> news:%23wpCmLrUDHA.2040@.TK2MSFTNGP11.phx.gbl...
> > 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" <danielbassNOJUNK@.MAILpostmaster.co.uk> wrote in message
> > news:urHxKGrUDHA.3972@.tk2msftngp13.phx.gbl...
> > > 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.
> >
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" <danielbassNOJUNK@.MAILpostmaster.co.uk> wrote in message
news:eiF8iorUDHA.2204@.TK2MSFTNGP10.phx.gbl...
> 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" <sjgengo@.aboutfortunate.com> wrote in message
> news:%23EiSajrUDHA.3312@.tk2msftngp13.phx.gbl...
> > 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" <danielbassNOJUNK@.MAILpostmaster.co.uk> wrote in message
> > news:up8BTXrUDHA.2248@.TK2MSFTNGP10.phx.gbl...
> > > 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" <sjgengo@.aboutfortunate.com> wrote in message
> > > news:%23wpCmLrUDHA.2040@.TK2MSFTNGP11.phx.gbl...
> > > > 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" <danielbassNOJUNK@.MAILpostmaster.co.uk> wrote in
message
> > > > news:urHxKGrUDHA.3972@.tk2msftngp13.phx.gbl...
> > > > > 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.
> > > > > > > > > > > >
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" <sjgengo@.aboutfortunate.com> wrote in message
news:eEdwWXvUDHA.1316@.TK2MSFTNGP12.phx.gbl...
> 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" <danielbassNOJUNK@.MAILpostmaster.co.uk> wrote in message
> news:eiF8iorUDHA.2204@.TK2MSFTNGP10.phx.gbl...
> > 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" <sjgengo@.aboutfortunate.com> wrote in message
> > news:%23EiSajrUDHA.3312@.tk2msftngp13.phx.gbl...
> > > 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" <danielbassNOJUNK@.MAILpostmaster.co.uk> wrote in message
> > > news:up8BTXrUDHA.2248@.TK2MSFTNGP10.phx.gbl...
> > > > 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" <sjgengo@.aboutfortunate.com> wrote in message
> > > > news:%23wpCmLrUDHA.2040@.TK2MSFTNGP11.phx.gbl...
> > > > > 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" <danielbassNOJUNK@.MAILpostmaster.co.uk> wrote in
> message
> > > > > news:urHxKGrUDHA.3972@.tk2msftngp13.phx.gbl...
> > > > > > 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.
> > > > > > > > > > > > > > > > > > > >
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" <sjgengo@.aboutfortunate.com> wrote in message
news:%23EiSajrUDHA.3312@.tk2msftngp13.phx.gbl...
> 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" <danielbassNOJUNK@.MAILpostmaster.co.uk> wrote in message
> news:up8BTXrUDHA.2248@.TK2MSFTNGP10.phx.gbl...
> > 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" <sjgengo@.aboutfortunate.com> wrote in message
> > news:%23wpCmLrUDHA.2040@.TK2MSFTNGP11.phx.gbl...
> > > 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" <danielbassNOJUNK@.MAILpostmaster.co.uk> wrote in message
> > > news:urHxKGrUDHA.3972@.tk2msftngp13.phx.gbl...
> > > > 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.
> > > > > >
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" <danielbassNOJUNK@.MAILpostmaster.co.uk> wrote in message
news:uT4ZaiOVDHA.2236@.TK2MSFTNGP12.phx.gbl...
> 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" <sjgengo@.aboutfortunate.com> wrote in message
> news:%23EiSajrUDHA.3312@.tk2msftngp13.phx.gbl...
> > 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" <danielbassNOJUNK@.MAILpostmaster.co.uk> wrote in message
> > news:up8BTXrUDHA.2248@.TK2MSFTNGP10.phx.gbl...
> > > 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" <sjgengo@.aboutfortunate.com> wrote in message
> > > news:%23wpCmLrUDHA.2040@.TK2MSFTNGP11.phx.gbl...
> > > > 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" <danielbassNOJUNK@.MAILpostmaster.co.uk> wrote in
message
> > > > news:urHxKGrUDHA.3972@.tk2msftngp13.phx.gbl...
> > > > > 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.
> > > > > > > > > > > >
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" <sjgengo@.aboutfortunate.com> wrote in message
news:e0ltpJRVDHA.2012@.TK2MSFTNGP10.phx.gbl...
> 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" <danielbassNOJUNK@.MAILpostmaster.co.uk> wrote in message
> news:O0AAKgOVDHA.1744@.TK2MSFTNGP12.phx.gbl...
> > 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" <sjgengo@.aboutfortunate.com> wrote in message
> > news:eEdwWXvUDHA.1316@.TK2MSFTNGP12.phx.gbl...
> > > 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" <danielbassNOJUNK@.MAILpostmaster.co.uk> wrote in message
> > > news:eiF8iorUDHA.2204@.TK2MSFTNGP10.phx.gbl...
> > > > 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" <sjgengo@.aboutfortunate.com> wrote in message
> > > > news:%23EiSajrUDHA.3312@.tk2msftngp13.phx.gbl...
> > > > > 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" <danielbassNOJUNK@.MAILpostmaster.co.uk> wrote in
> message
> > > > > news:up8BTXrUDHA.2248@.TK2MSFTNGP10.phx.gbl...
> > > > > > 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" <sjgengo@.aboutfortunate.com> wrote in message
> > > > > > news:%23wpCmLrUDHA.2040@.TK2MSFTNGP11.phx.gbl...
> > > > > > > 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" <danielbassNOJUNK@.MAILpostmaster.co.uk> wrote in
> > > message
> > > > > > > news:urHxKGrUDHA.3972@.tk2msftngp13.phx.gbl...
> > > > > > > > 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.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
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" <danielbassNOJUNK@.MAILpostmaster.co.uk> wrote in message
news:OEDfQQRVDHA.2004@.TK2MSFTNGP10.phx.gbl...
> 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" <sjgengo@.aboutfortunate.com> wrote in message
> news:e0ltpJRVDHA.2012@.TK2MSFTNGP10.phx.gbl...
> > 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" <danielbassNOJUNK@.MAILpostmaster.co.uk> wrote in message
> > news:O0AAKgOVDHA.1744@.TK2MSFTNGP12.phx.gbl...
> > > 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" <sjgengo@.aboutfortunate.com> wrote in message
> > > news:eEdwWXvUDHA.1316@.TK2MSFTNGP12.phx.gbl...
> > > > 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" <danielbassNOJUNK@.MAILpostmaster.co.uk> wrote in
message
> > > > news:eiF8iorUDHA.2204@.TK2MSFTNGP10.phx.gbl...
> > > > > 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" <sjgengo@.aboutfortunate.com> wrote in message
> > > > > news:%23EiSajrUDHA.3312@.tk2msftngp13.phx.gbl...
> > > > > > 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" <danielbassNOJUNK@.MAILpostmaster.co.uk> wrote in
> > message
> > > > > > news:up8BTXrUDHA.2248@.TK2MSFTNGP10.phx.gbl...
> > > > > > > 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" <sjgengo@.aboutfortunate.com> wrote in
message
> > > > > > > news:%23wpCmLrUDHA.2040@.TK2MSFTNGP11.phx.gbl...
> > > > > > > > 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" <danielbassNOJUNK@.MAILpostmaster.co.uk> wrote
in
> > > > message
> > > > > > > > news:urHxKGrUDHA.3972@.tk2msftngp13.phx.gbl...
> > > > > > > > > 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.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
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" <sjgengo@.aboutfortunate.com> wrote in message
news:%23dqR9%23RVDHA.2040@.TK2MSFTNGP11.phx.gbl...
> 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" <danielbassNOJUNK@.MAILpostmaster.co.uk> wrote in message
> news:OEDfQQRVDHA.2004@.TK2MSFTNGP10.phx.gbl...
> > 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" <sjgengo@.aboutfortunate.com> wrote in message
> > news:e0ltpJRVDHA.2012@.TK2MSFTNGP10.phx.gbl...
> > > 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" <danielbassNOJUNK@.MAILpostmaster.co.uk> wrote in message
> > > news:O0AAKgOVDHA.1744@.TK2MSFTNGP12.phx.gbl...
> > > > 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" <sjgengo@.aboutfortunate.com> wrote in message
> > > > news:eEdwWXvUDHA.1316@.TK2MSFTNGP12.phx.gbl...
> > > > > 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" <danielbassNOJUNK@.MAILpostmaster.co.uk> wrote in
> message
> > > > > news:eiF8iorUDHA.2204@.TK2MSFTNGP10.phx.gbl...
> > > > > > 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" <sjgengo@.aboutfortunate.com> wrote in message
> > > > > > news:%23EiSajrUDHA.3312@.tk2msftngp13.phx.gbl...
> > > > > > > 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" <danielbassNOJUNK@.MAILpostmaster.co.uk> wrote in
> > > message
> > > > > > > news:up8BTXrUDHA.2248@.TK2MSFTNGP10.phx.gbl...
> > > > > > > > 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" <sjgengo@.aboutfortunate.com> wrote in
> message
> > > > > > > > news:%23wpCmLrUDHA.2040@.TK2MSFTNGP11.phx.gbl...
> > > > > > > > > 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" <danielbassNOJUNK@.MAILpostmaster.co.uk>
wrote
> in
> > > > > message
> > > > > > > > > news:urHxKGrUDHA.3972@.tk2msftngp13.phx.gbl...
> > > > > > > > > > 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.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >

0 comments:

Post a Comment