Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 16th, 2009, 08:23 AM
Registered User
 
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rupen
Default Change the order of client script / server script

Hi All,

I have used OnClientClick method of server button control, but the script executes before the server-side code written in the click event of server button control, which i need to swap, i.e. server-side code should be executed first and then the client script.

Thanks in advance.
 
Old April 16th, 2009, 01:29 PM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 207
Thanks: 2
Thanked 15 Times in 15 Posts
Default Well...

the OnClient executes first because that event happens first... you could registerclientscriptblock and have that run after the server side code?

something like
Code:
Protected Sub Button1_Click (ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

        'Your server side code here

        Dim strScript As New StringBuilder
        strScript.Append("<script language='javascript' type='text/javascript'>")
        strScript.Append("alert('This alert is happening after the post back!');")
        strScript.Append("</" & "script>")
        Page.ClientScript.RegisterClientScriptBlock(Page.GetType, "ClientScript", strScript.ToString, False)


End Sub
__________________
Jason Hall

Follow me on Twitter @jhall2013
 
Old April 16th, 2009, 01:35 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Sorry to say this, but what's the point?? the Whole point of executing client script before server script is to avoid the round trip between client and server... if you will be doing the trip, why not execute just all the code in the server???
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old April 16th, 2009, 01:41 PM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 207
Thanks: 2
Thanked 15 Times in 15 Posts
Default I agree...

I don't really see the point but i was just giving an option as to what they could do... Perhaps there is a valid reason (but i doubt it)
__________________
Jason Hall

Follow me on Twitter @jhall2013





Similar Threads
Thread Thread Starter Forum Replies Last Post
Client Side Script Not Working sramesh ASP.NET 2.0 Basics 3 August 2nd, 2007 03:56 PM
how to pass data from Client to server script pushpa Classic ASP Basics 8 March 11th, 2007 04:30 AM
Problem with client side script cschng Classic ASP Basics 2 May 23rd, 2005 12:43 AM
Postback from client script gp_mk HTML Code Clinic 2 April 14th, 2004 02:48 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.