Saturday, March 31, 2012

Server side code in-side aspx

I usually use code-behind pages in ASP.Net, but occasionally I have to put my
server code inside an aspx file.
I have a problem finding the correct signature for a button click event.
Private Sub loginbtn_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles loginbtn.Click
compiles in in code behind, but it doesn't compile inside an aspx file.

How can I write a server event handler and put the code inside an asp file?That is the correct signature. What's the error you get?

-Brock
DevelopMentor
http://staff.develop.com/ballen

> I usually use code-behind pages in ASP.Net, but occasionally I have to
> put my
> server code inside an aspx file.
> I have a problem finding the correct signature for a button click
> event.
> Private Sub loginbtn_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles loginbtn.Click
> compiles in in code behind, but it doesn't compile inside an aspx
> file.
> How can I write a server event handler and put the code inside an asp
> file?

Server Side Code dependent on JavaScript

Is there a way I can launch a Server Side function from JavaScript?

On a Button Click, I am using JavaScript to print to current page. When the print has been sent, I want to run a Server Side Function to update a record (which also changes the screen so I have to wait until it prints to run the server side function).

Thanks.I imagine in your JS function, you could print and then do a postback to the server?
This may get your problem resolved.

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
Button1.Attributes.Add("onClick","javascript:DoSomething();");
string html = "";
html += "<script>";
html += " function DoSomething()";
html += " {";
html += " window.print();";
html += " }";
html += "</script>";
Response.Write(html);
}

private void Button1_Click(object sender, System.EventArgs e)
{
Update();
}

public void Update()
{
Response.Write("Now going to update the record.");
}
How to force a postback using javascript:

http://weblogs.asp.net/mnolton/archive/2003/06/04/8260.aspx

server side code access the text of <asp:label> changed by client-side javascript co

Is possible for server side code to access the text of <asp:label> changed
by client side javascript code?Yes, of course you can do it.

--
-Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com

"nick" <nbdy9.removethis@.hotmail.com> wrote in message
news:%23UAnyAt4EHA.2600@.TK2MSFTNGP09.phx.gbl...
> Is possible for server side code to access the text of <asp:label> changed
> by client side javascript code?
No, you will need to double the new value into a hidden text field, or some
other postable field, and then look for the change of the text through the
Request.Forms["txtHidden1"] property on postback to determine if the text
has changed.

bill

"nick" <nbdy9.removethis@.hotmail.com> wrote in message
news:%23UAnyAt4EHA.2600@.TK2MSFTNGP09.phx.gbl...
> Is possible for server side code to access the text of <asp:label> changed
> by client side javascript code?
If you mean accessing the text via the label's Text property, the answer is
no.

You can pass the changed text to the server in one of the common ways of
passing values from client to server, for example in a hidden field.

Eliyahu

"nick" <nbdy9.removethis@.hotmail.com> wrote in message
news:%23UAnyAt4EHA.2600@.TK2MSFTNGP09.phx.gbl...
> Is possible for server side code to access the text of <asp:label> changed
> by client side javascript code?

server side code access the text of <asp:label> changed by client-side javascri

Is possible for server side code to access the text of <asp:label> changed
by client side javascript code?Yes, of course you can do it.
-Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com
"nick" <nbdy9.removethis@.hotmail.com> wrote in message
news:%23UAnyAt4EHA.2600@.TK2MSFTNGP09.phx.gbl...
> Is possible for server side code to access the text of <asp:label> changed
> by client side javascript code?
>
No, you will need to double the new value into a hidden text field, or some
other postable field, and then look for the change of the text through the
Request.Forms["txtHidden1"] property on postback to determine if the text
has changed.
bill
"nick" <nbdy9.removethis@.hotmail.com> wrote in message
news:%23UAnyAt4EHA.2600@.TK2MSFTNGP09.phx.gbl...
> Is possible for server side code to access the text of <asp:label> changed
> by client side javascript code?
>
If you mean accessing the text via the label's Text property, the answer is
no.
You can pass the changed text to the server in one of the common ways of
passing values from client to server, for example in a hidden field.
Eliyahu
"nick" <nbdy9.removethis@.hotmail.com> wrote in message
news:%23UAnyAt4EHA.2600@.TK2MSFTNGP09.phx.gbl...
> Is possible for server side code to access the text of <asp:label> changed
> by client side javascript code?
>

Server Side Code..

How to decide to use WebControls.Button or HtmlControls.HtmlInputButton
controls in a web application. When I am getting the clicked event handler
for both of them on the server side. Thanks,

NelsonHi Nelson,

I would definitely go with the <asp:Button> in your case and use code
behind. This makes it easy to hook up your code if you are using an IDE
like VS.Net and will seperate your code from your UI. Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"Nelson" <NelsonSmith1997@.hotmail.com> wrote in message
news:evpYtjRyEHA.3224@.TK2MSFTNGP14.phx.gbl...
> How to decide to use WebControls.Button or HtmlControls.HtmlInputButton
> controls in a web application. When I am getting the clicked event handler
> for both of them on the server side. Thanks,
> Nelson
>

Server Side code withoout page refresh

Is it possible if I can call server side code without the page
refreshing?

Thanks,

SeanShort answer : no, if it's a postback.
On the first call, yes, of course.

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
<seanmle@.gmail.com> wrote in message news:1140807565.766741.128340@.v46g2000cwv.googlegr oups.com...
> Is it possible if I can call server side code without the page
> refreshing?
> Thanks,
> Sean
yes. the techinque is call AJAX. google for toolkits. also asp.net 2.0 has a
very simple (feature wise) implementation for IE.

-- bruce (sqlwork.com)

<seanmle@.gmail.com> wrote in message
news:1140807565.766741.128340@.v46g2000cwv.googlegr oups.com...
> Is it possible if I can call server side code without the page
> refreshing?
> Thanks,
> Sean
Yes.
You can use Remote Scripting callbacks (often now referred to as "AJAX").
This normally involves using XmlHttp from the client - side page DOM to make
a call into the server-side page and call a method on it, returning the
results as either javascript, JSON, or HTML which is used to update the DOM
at the client.

The new Atlas Framework does this for ASP.NET 2.0. You could also look at
Anthem.Net and MagicAJax.net over on Sourceforge.net if you are interested in
using a whole "framework" for this type of operation.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com

"seanmle@.gmail.com" wrote:

> Is it possible if I can call server side code without the page
> refreshing?
> Thanks,
> Sean
>
Here you can find a comparison of AJAX frameworks, that allow page
updates with AJAX without reloading the whole page:
http://www.daniel-zeiss.de/AJAXComparison/Results.htm

Some frameworks allow roundtrips with ASP.NET server events without
updating any page content.
re:
>> Is it possible if I can call server side code without the page refreshing?
> yes. the techinque is call AJAX.

Sure, although you're still posting back...just not the whole page.

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Bruce Barker" <brubar_nospamplease_@.safeco.com> wrote in message
news:e9I1uAYOGHA.3888@.TK2MSFTNGP10.phx.gbl...
> yes. the techinque is call AJAX. google for toolkits. also asp.net 2.0 has a very simple (feature
> wise) implementation for IE.
> -- bruce (sqlwork.com)

> <seanmle@.gmail.com> wrote in message news:1140807565.766741.128340@.v46g2000cwv.googlegr oups.com...
>> Is it possible if I can call server side code without the page
>> refreshing?
>>
>> Thanks,
>>
>> Sean

Server Side code withoout page refresh

Is it possible if I can call server side code without the page
refreshing?
Thanks,
SeanShort answer : no, if it's a postback.
On the first call, yes, of course.
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
<seanmle@.gmail.com> wrote in message news:1140807565.766741.128340@.v46g2000cwv.googlegroups
.com...
> Is it possible if I can call server side code without the page
> refreshing?
> Thanks,
> Sean
>
yes. the techinque is call AJAX. google for toolkits. also asp.net 2.0 has a
very simple (feature wise) implementation for IE.
-- bruce (sqlwork.com)
<seanmle@.gmail.com> wrote in message
news:1140807565.766741.128340@.v46g2000cwv.googlegroups.com...
> Is it possible if I can call server side code without the page
> refreshing?
> Thanks,
> Sean
>
Yes.
You can use Remote Scripting callbacks (often now referred to as "AJAX").
This normally involves using XmlHttp from the client - side page DOM to make
a call into the server-side page and call a method on it, returning the
results as either javascript, JSON, or HTML which is used to update the DOM
at the client.
The new Atlas Framework does this for ASP.NET 2.0. You could also look at
Anthem.Net and MagicAJax.net over on Sourceforge.net if you are interested i
n
using a whole "framework" for this type of operation.
Peter
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"seanmle@.gmail.com" wrote:

> Is it possible if I can call server side code without the page
> refreshing?
> Thanks,
> Sean
>
Here you can find a comparison of AJAX frameworks, that allow page
updates with AJAX without reloading the whole page:
http://www.daniel-zeiss.de/AJAXComparison/Results.htm
Some frameworks allow roundtrips with ASP.NET server events without
updating any page content.
re:
> yes. the techinque is call AJAX.
Sure, although you're still posting back...just not the whole page.
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Bruce Barker" <brubar_nospamplease_@.safeco.com> wrote in message
news:e9I1uAYOGHA.3888@.TK2MSFTNGP10.phx.gbl...
> yes. the techinque is call AJAX. google for toolkits. also asp.net 2.0 has
a very simple (feature
> wise) implementation for IE.
> -- bruce (sqlwork.com)
> <seanmle@.gmail.com> wrote in message news:1140807565.766741.128340@.v46g200
0cwv.googlegroups.com...

Server side code in-side aspx

I usually use code-behind pages in ASP.Net, but occasionally I have to put m
y
server code inside an aspx file.
I have a problem finding the correct signature for a button click event.
Private Sub loginbtn_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles loginbtn.Click
compiles in in code behind, but it doesn't compile inside an aspx file.
How can I write a server event handler and put the code inside an asp file?That is the correct signature. What's the error you get?
-Brock
DevelopMentor
http://staff.develop.com/ballen

> I usually use code-behind pages in ASP.Net, but occasionally I have to
> put my
> server code inside an aspx file.
> I have a problem finding the correct signature for a button click
> event.
> Private Sub loginbtn_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles loginbtn.Click
> compiles in in code behind, but it doesn't compile inside an aspx
> file.
> How can I write a server event handler and put the code inside an asp
> file?
>

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