Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Run Server-side Function *immediately after* executing client-side JavaScript.

Reply
Thread Tools

Run Server-side Function *immediately after* executing client-side JavaScript.

 
 
Guadala Harry
Guest
Posts: n/a
 
      06-13-2004
Suppose I have a hyperlink that, when clicked, executes a JavaScript
function on the client. Separately I have a button that, when clicked,
causes a post back and executes a server-side function, as in the following:

<a id="HyperLink5" href="javascriptoSomethingInClient()">Do Something</a>

<asp:Button id="btnSaveChanges" EnableViewState="true"
CommandName="SaveChanges" Visible="true" Width="115" runat="server"
Text="Save Changes"></asp:Button>

What I want is to have it so that when the user clicks on the hyperlink, the
JavaScript function executes and then the PostBack gets initiated
immediately after the JavaScript function does its thing - as if the user
had clicked on the Save Changes button (but without requiring the user to
click on the button). That is, I want the JavaScript to make its client-side
changes and then cause the server-side "Save Changes" function to execute.
Any ideas?

Thanks!


 
Reply With Quote
 
 
 
 
John Saunders
Guest
Posts: n/a
 
      06-13-2004
"Guadala Harry" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Suppose I have a hyperlink that, when clicked, executes a JavaScript
> function on the client. Separately I have a button that, when clicked,
> causes a post back and executes a server-side function, as in the

following:
>
> <a id="HyperLink5" href="javascriptoSomethingInClient()">Do

Something</a>
>
> <asp:Button id="btnSaveChanges" EnableViewState="true"
> CommandName="SaveChanges" Visible="true" Width="115" runat="server"
> Text="Save Changes"></asp:Button>
>
> What I want is to have it so that when the user clicks on the hyperlink,

the
> JavaScript function executes and then the PostBack gets initiated
> immediately after the JavaScript function does its thing - as if the user
> had clicked on the Save Changes button (but without requiring the user to
> click on the button). That is, I want the JavaScript to make its

client-side
> changes and then cause the server-side "Save Changes" function to execute.
> Any ideas?


Use btnSaveChanges.click() in DoSomethingInClient.
--
John Saunders
johnwsaundersiii at hotmail


 
Reply With Quote
 
 
 
 
Guadala Harry
Guest
Posts: n/a
 
      06-13-2004
Sorry if I'm a bit dense on this, but here is the syntax I used and it
doesn't trigger the server-side code:

function DoSomethingInClient() {
Do Some Stuff Here
btnSaveChanges.click();
}

How can I get the server-side code (btnSaveChanges.click()) to execute?

Thanks.


"John Saunders" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> "Guadala Harry" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > Suppose I have a hyperlink that, when clicked, executes a JavaScript
> > function on the client. Separately I have a button that, when clicked,
> > causes a post back and executes a server-side function, as in the

> following:
> >
> > <a id="HyperLink5" href="javascriptoSomethingInClient()">Do

> Something</a>
> >
> > <asp:Button id="btnSaveChanges" EnableViewState="true"
> > CommandName="SaveChanges" Visible="true" Width="115" runat="server"
> > Text="Save Changes"></asp:Button>
> >
> > What I want is to have it so that when the user clicks on the hyperlink,

> the
> > JavaScript function executes and then the PostBack gets initiated
> > immediately after the JavaScript function does its thing - as if the

user
> > had clicked on the Save Changes button (but without requiring the user

to
> > click on the button). That is, I want the JavaScript to make its

> client-side
> > changes and then cause the server-side "Save Changes" function to

execute.
> > Any ideas?

>
> Use btnSaveChanges.click() in DoSomethingInClient.
> --
> John Saunders
> johnwsaundersiii at hotmail
>
>



 
Reply With Quote
 
John Saunders
Guest
Posts: n/a
 
      06-14-2004
"Guadala Harry" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Sorry if I'm a bit dense on this, but here is the syntax I used and it
> doesn't trigger the server-side code:
>
> function DoSomethingInClient() {
> Do Some Stuff Here
> btnSaveChanges.click();
> }
>
> How can I get the server-side code (btnSaveChanges.click()) to execute?


I'm surprised that didn't work.

In server code, you can call GetPostBackClientEvent(btnSaveChanges) to get a
string containing a JavaScript function which can be called to do a
postback. I'll research this a bit and get you back some code.
--
John Saunders
johnwsaundersiii at hotmail


> "John Saunders" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > "Guadala Harry" <(E-Mail Removed)> wrote in message
> > news:%(E-Mail Removed)...
> > > Suppose I have a hyperlink that, when clicked, executes a JavaScript
> > > function on the client. Separately I have a button that, when clicked,
> > > causes a post back and executes a server-side function, as in the

> > following:
> > >
> > > <a id="HyperLink5" href="javascriptoSomethingInClient()">Do

> > Something</a>
> > >
> > > <asp:Button id="btnSaveChanges" EnableViewState="true"
> > > CommandName="SaveChanges" Visible="true" Width="115" runat="server"
> > > Text="Save Changes"></asp:Button>
> > >
> > > What I want is to have it so that when the user clicks on the

hyperlink,
> > the
> > > JavaScript function executes and then the PostBack gets initiated
> > > immediately after the JavaScript function does its thing - as if the

> user
> > > had clicked on the Save Changes button (but without requiring the user

> to
> > > click on the button). That is, I want the JavaScript to make its

> > client-side
> > > changes and then cause the server-side "Save Changes" function to

> execute.
> > > Any ideas?

> >
> > Use btnSaveChanges.click() in DoSomethingInClient.
> > --
> > John Saunders
> > johnwsaundersiii at hotmail
> >
> >

>
>



 
Reply With Quote
 
=?Utf-8?B?aGFyaSBwcmFzYWQ=?=
Guest
Posts: n/a
 
      06-15-2004
Hi
You can call Server Side Script from Client Script Execution.
function DoSomethingInClient()
{
Do Some Stuff Here
__doPostBack('btnSaveClick','');
}
I am using same code and its working for me....








"John Saunders" wrote:

> "Guadala Harry" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Sorry if I'm a bit dense on this, but here is the syntax I used and it
> > doesn't trigger the server-side code:
> >
> > function DoSomethingInClient() {
> > Do Some Stuff Here
> > btnSaveChanges.click();
> > }
> >
> > How can I get the server-side code (btnSaveChanges.click()) to execute?

>
> I'm surprised that didn't work.
>
> In server code, you can call GetPostBackClientEvent(btnSaveChanges) to get a
> string containing a JavaScript function which can be called to do a
> postback. I'll research this a bit and get you back some code.
> --
> John Saunders
> johnwsaundersiii at hotmail
>
>
> > "John Saunders" <(E-Mail Removed)> wrote in message
> > news:%(E-Mail Removed)...
> > > "Guadala Harry" <(E-Mail Removed)> wrote in message
> > > news:%(E-Mail Removed)...
> > > > Suppose I have a hyperlink that, when clicked, executes a JavaScript
> > > > function on the client. Separately I have a button that, when clicked,
> > > > causes a post back and executes a server-side function, as in the
> > > following:
> > > >
> > > > <a id="HyperLink5" href="javascriptoSomethingInClient()">Do
> > > Something</a>
> > > >
> > > > <asp:Button id="btnSaveChanges" EnableViewState="true"
> > > > CommandName="SaveChanges" Visible="true" Width="115" runat="server"
> > > > Text="Save Changes"></asp:Button>
> > > >
> > > > What I want is to have it so that when the user clicks on the

> hyperlink,
> > > the
> > > > JavaScript function executes and then the PostBack gets initiated
> > > > immediately after the JavaScript function does its thing - as if the

> > user
> > > > had clicked on the Save Changes button (but without requiring the user

> > to
> > > > click on the button). That is, I want the JavaScript to make its
> > > client-side
> > > > changes and then cause the server-side "Save Changes" function to

> > execute.
> > > > Any ideas?
> > >
> > > Use btnSaveChanges.click() in DoSomethingInClient.
> > > --
> > > John Saunders
> > > johnwsaundersiii at hotmail
> > >
> > >

> >
> >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
EMBEDDING > Run Python & Run C Function anonymisiert85@mymail.ch Python 3 06-23-2007 04:15 AM
Run Javascript in asp:updatepanel, not executing !? jesper_lofgren@yahoo.se ASP .Net 0 01-17-2007 09:55 PM
executing c++ program under unix, unable to run the application yazwas@gmail.com C++ 1 02-22-2006 02:59 PM
write a function such that when ever i call this function in some other function .it should give me tha data type and value of calling function parameter komal C++ 6 01-25-2005 11:13 AM
Add Event Handler Dynamically, but assigning function name at run-time, not to static function Jose Suero ASP .Net 2 12-26-2003 08:40 PM



Advertisments