Showing posts with label onclick. Show all posts
Showing posts with label onclick. Show all posts

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.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >

Server Side Controls in ASP.NET

Hi,

I have an aspx page with some server side textboxes.

I have a button onmy page which allows users to add data
to a database.

In my onclick event for my button when I try and get teh
value from the textbox using..

Dim myString as String = textbox1.text

...it is blank.

When I do a..

Dim myString = Request.Form("textbox1")

...I get the value the user enetered.

I have declared my textbox as a control in my codebehind.

And it is an asp.net textbox.

Any ideas why this is?

This is baffling me.

Kerri.Have you added the "runat=server" attribute to the template HTML for the
text box?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Kerri" <anonymous@.discussions.microsoft.com> wrote in message
news:017401c39cc4$12c55070$a501280a@.phx.gbl...
> Hi,
> I have an aspx page with some server side textboxes.
> I have a button onmy page which allows users to add data
> to a database.
> In my onclick event for my button when I try and get teh
> value from the textbox using..
> Dim myString as String = textbox1.text
> ..it is blank.
> When I do a..
> Dim myString = Request.Form("textbox1")
> ..I get the value the user enetered.
> I have declared my textbox as a control in my codebehind.
> And it is an asp.net textbox.
> Any ideas why this is?
> This is baffling me.
> Kerri.

Server side functionality

Hi All,

I have an html button on .aspx page.

<INPUT class="sbttn" id="btnComplete0" onclick="onComplete
()" type="button" value="Mark Completed"
name="btnComplete0"
When the user clicks on the html button the OnComplete
function is called.

<script language="javascript">
function onComplete()
{

// Client side code

// Clicking the server control via code
WorkItemForm.btnComplete.click();

}
</script
I need to perform some server side functinality whenever
user clicks the html button. So I place a hidden server
control (id = btnComplete) on the .aspx page. In the
client side code I automatically click the server control
( WorkItemForm.btnComplete.click();).

On the click event of hidden server control, I write the
server side code in .aspx.cs page.

// Code in .aspx.cs page

private void btnComplete_Click(object sender,
System.EventArgs e)
{
// Calling Server Side Code
}

I am using btnComplete server control as an intermediate
to perform server side functionality.

Problem:

I want to get rid of server control.
Is there a way to perform server side functionality
directly without using server control.

I tried document.FormName.Submit();

This doesn't work. Is there some other way to do so?

Thanks & Regards,
-ReetuHi Reetu,

Here's some VB code that might help you. It uses the submit() method. Not sure
why it didn't work for you.

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Literal1.Text = "<script>function
onCompleted(){alert('action');document.forms[0].submit();}</script>"
If IsPostBack Then
Label2.Text = "I was posted back at: " & Now.TimeOfDay.ToString
End If
End Sub

<form id="Form1" method="post" runat="server">
<p>
<asp:textbox id="TextBox1" runat="server"></asp:textbox></p>
<p>
<asp:label id="Label2" runat="server"></asp:label></p>
<p>
<asp:label id="Label1" runat="server"></asp:label></p>
<p>
<asp:literal id="Literal1" runat="server"></asp:literal></p>
<p> </p>
<p> </p>
<input class="sbttn" id="btnComplete0" onclick="onCompleted()"
type="button" value="Mark Completed"
name="btnComplete0">
</form
"Reetu" <reetu@.ascentn.com> wrote in message
news:06c901c35c60$5aabcc10$a301280a@.phx.gbl...
Hi All,

I have an html button on .aspx page.

<INPUT class="sbttn" id="btnComplete0" onclick="onComplete
()" type="button" value="Mark Completed"
name="btnComplete0"
When the user clicks on the html button the OnComplete
function is called.

<script language="javascript">
function onComplete()
{

// Client side code

// Clicking the server control via code
WorkItemForm.btnComplete.click();

}
</script
I need to perform some server side functinality whenever
user clicks the html button. So I place a hidden server
control (id = btnComplete) on the .aspx page. In the
client side code I automatically click the server control
( WorkItemForm.btnComplete.click();).

On the click event of hidden server control, I write the
server side code in .aspx.cs page.

// Code in .aspx.cs page

private void btnComplete_Click(object sender,
System.EventArgs e)
{
// Calling Server Side Code
}

I am using btnComplete server control as an intermediate
to perform server side functionality.

Problem:

I want to get rid of server control.
Is there a way to perform server side functionality
directly without using server control.

I tried document.FormName.Submit();

This doesn't work. Is there some other way to do so?

Thanks & Regards,
-Reetu

When your page is loaded, checl the HTML source of your page. Your
hidden button will not be rendered at all.

Instead, you can convert your button to a aspx button and add
Javascript event to it from the code behind using

Add this line of code to your page load event.
ButtonName.Attributes.add("onClick","return onComplete()")

Now when you click on your button it will raise the onclick event on
the client side and will call onComplete Javascript function. Inside
the Javascript if you return false, the form will not be submitted and
the server side event of your button will not fire. If you return
true, form will be submitted to the server and your button's onclick
event will be fired on the server.

--
Ram

"Reetu" <reetu@.ascentn.com> wrote in message news:<06c901c35c60$5aabcc10$a301280a@.phx.gbl>...
> Hi All,
> I have an html button on .aspx page.
> <INPUT class="sbttn" id="btnComplete0" onclick="onComplete
> ()" type="button" value="Mark Completed"
> name="btnComplete0">
> When the user clicks on the html button the OnComplete
> function is called.
> <script language="javascript">
> function onComplete()
> {
> // Client side code
> // Clicking the server control via code
> WorkItemForm.btnComplete.click();
> }
> </script>
>
> I need to perform some server side functinality whenever
> user clicks the html button. So I place a hidden server
> control (id = btnComplete) on the .aspx page. In the
> client side code I automatically click the server control
> ( WorkItemForm.btnComplete.click();).
> On the click event of hidden server control, I write the
> server side code in .aspx.cs page.
> // Code in .aspx.cs page
> private void btnComplete_Click(object sender,
> System.EventArgs e)
> {
> // Calling Server Side Code
> }
> I am using btnComplete server control as an intermediate
> to perform server side functionality.
> Problem:
> I want to get rid of server control.
> Is there a way to perform server side functionality
> directly without using server control.
> I tried document.FormName.Submit();
> This doesn't work. Is there some other way to do so?
> Thanks & Regards,
> -Reetu
Thanks a lot, it works.

Regards,
-Reetu

>--Original Message--
>When your page is loaded, checl the HTML source of your
page. Your
>hidden button will not be rendered at all.
>Instead, you can convert your button to a aspx button and
add
>Javascript event to it from the code behind using
>Add this line of code to your page load event.
>ButtonName.Attributes.add("onClick","return onComplete()")
>Now when you click on your button it will raise the
onclick event on
>the client side and will call onComplete Javascript
function. Inside
>the Javascript if you return false, the form will not be
submitted and
>the server side event of your button will not fire. If
you return
>true, form will be submitted to the server and your
button's onclick
>event will be fired on the server.
>--
>Ram
>"Reetu" <reetu@.ascentn.com> wrote in message
news:<06c901c35c60$5aabcc10$a301280a@.phx.gbl>...
>> Hi All,
>>
>> I have an html button on .aspx page.
>>
>> <INPUT class="sbttn" id="btnComplete0"
onclick="onComplete
>> ()" type="button" value="Mark Completed"
>> name="btnComplete0">
>>
>> When the user clicks on the html button the OnComplete
>> function is called.
>>
>> <script language="javascript">
>> function onComplete()
>> {
>>
>> // Client side code
>>
>> // Clicking the server control via code
>> WorkItemForm.btnComplete.click();
>>
>> }
>> </script>
>>
>>
>> I need to perform some server side functinality
whenever
>> user clicks the html button. So I place a hidden server
>> control (id = btnComplete) on the .aspx page. In the
>> client side code I automatically click the server
control
>> ( WorkItemForm.btnComplete.click();).
>>
>> On the click event of hidden server control, I write
the
>> server side code in .aspx.cs page.
>>
>> // Code in .aspx.cs page
>>
>> private void btnComplete_Click(object sender,
>> System.EventArgs e)
>> {
>> // Calling Server Side Code
>> }
>>
>> I am using btnComplete server control as an
intermediate
>> to perform server side functionality.
>>
>> Problem:
>>
>> I want to get rid of server control.
>> Is there a way to perform server side functionality
>> directly without using server control.
>>
>> I tried document.FormName.Submit();
>>
>> This doesn't work. Is there some other way to do so?
>>
>> Thanks & Regards,
>> -Reetu
>.

Monday, March 26, 2012

Server tag not well formed

This thing always gets me.

onclick="DisplayExamMessage('<%# Eval("Description") %>')"

Any ideas!

What is the onclick coming from? A Button or a picture?


Its a asp.net hyperlink control.

<asp:HyperLink id="hlDescription" onclick="DisplayExamMessage()" NavigateUrl="#" Text="Read Description" runat="server"> </asp:HyperLink

Try

onclick=<%# DisplayExamMessage(Eval("Description").ToString()) %>


Hi,

But DisplayExamMessage is a JavaScript function.

onclick=<%# DisplayExamMessage(Eval("Description").ToString()) %>

Function DisplayExamMessage(ByVal t As String)

Return "DisplayExamMessage('" & t & "');"
End Function

Ugly but should work


I see.

Add DisplayExamMessage() to your server script. Then, do this:

protected string DisplayExamMessage(string descrition)
{
if(descrition.Trim().Length != 0)
return "javascript:DisplayExamMessage(" + descrition + ");"; //I use same name for your

//server script and javascript. You can use different name

else
return string.Empty;
}