473,806 Members | 2,707 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Call server side code from client side

Hi,

I have an ASP .NET page, that runs client side timer that
does something on the Server side and after that loads
another page. So I have on client side something like :

function OnPageLoad()
{
setTimeout("OnT imer()", 10000);
}

function OnTimer()
{
ServerMethod();
}

<body onload="OnPageL oad()">
<form id="Form1" method="post" runat="server">

It does not work, and I understand why - client side does
not know what is ServerMethod();

How to call server side method from the timer callback ?
Meanwhile I found workaround : created in Form1 tiny
disabled button DummyBtn "runat=serv er", defined such
server-side event handler for click :

void DummyBtn_Server Click(object obj,EventArgs e)
{
ServerMethod();
}

and on the client side in OnTimer method wrote

Form1.DummyBtn. click();

So the timer simulates click of DummyBtn, click runs its
event handler, the event handler in turn calls the server
method.

It works, but it is ugly solution. I 'd like to call
ServerMethod() from the timer callback directly, without
tricks like this. Is it possible ?

Nov 17 '05 #1
3 6934
You can use the web service behavior for this. (WebService.htc )
This technique works with IE only.
Here's more details:
http://msdn.microsoft.com/library/de...s/overview.asp

http://msdn.microsoft.com/downloads/...ce/default.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com

"Borr" <an*******@disc ussions.microso ft.com> wrote in message
news:05******** *************** *****@phx.gbl.. .
Hi,

I have an ASP .NET page, that runs client side timer that
does something on the Server side and after that loads
another page. So I have on client side something like :

function OnPageLoad()
{
setTimeout("OnT imer()", 10000);
}

function OnTimer()
{
ServerMethod();
}

<body onload="OnPageL oad()">
<form id="Form1" method="post" runat="server">

It does not work, and I understand why - client side does
not know what is ServerMethod();

How to call server side method from the timer callback ?
Meanwhile I found workaround : created in Form1 tiny
disabled button DummyBtn "runat=serv er", defined such
server-side event handler for click :

void DummyBtn_Server Click(object obj,EventArgs e)
{
ServerMethod();
}

and on the client side in OnTimer method wrote

Form1.DummyBtn. click();

So the timer simulates click of DummyBtn, click runs its
event handler, the event handler in turn calls the server
method.

It works, but it is ugly solution. I 'd like to call
ServerMethod() from the timer callback directly, without
tricks like this. Is it possible ?

Nov 17 '05 #2
Jj
there is no direct live connection between the client side and server side,
because HTTP is a stateless connetion type.

Unlesss you use something like ActiveX, or Java applet, the only way you can
communicate between the client and server sides are doing the form posting.

Alone this line, you can call form.submit() method in your timer method and
activate the server side methods.

Jianjun
"Borr" <an*******@disc ussions.microso ft.com> wrote in message
news:05******** *************** *****@phx.gbl.. .
Hi,

I have an ASP .NET page, that runs client side timer that
does something on the Server side and after that loads
another page. So I have on client side something like :

function OnPageLoad()
{
setTimeout("OnT imer()", 10000);
}

function OnTimer()
{
ServerMethod();
}

<body onload="OnPageL oad()">
<form id="Form1" method="post" runat="server">

It does not work, and I understand why - client side does
not know what is ServerMethod();

How to call server side method from the timer callback ?
Meanwhile I found workaround : created in Form1 tiny
disabled button DummyBtn "runat=serv er", defined such
server-side event handler for click :

void DummyBtn_Server Click(object obj,EventArgs e)
{
ServerMethod();
}

and on the client side in OnTimer method wrote

Form1.DummyBtn. click();

So the timer simulates click of DummyBtn, click runs its
event handler, the event handler in turn calls the server
method.

It works, but it is ugly solution. I 'd like to call
ServerMethod() from the timer callback directly, without
tricks like this. Is it possible ?

Nov 17 '05 #3
That's not entirely true, you can use server side blocks to execute methods
on the server-side although it is a somewhat advanced technique.

--
-----------
Got TidBits?
Get it here: www.networkip.net/tidbits
"Jj" <ji*******@yaho o.com> wrote in message
news:q9******** ************@co mcast.com...
there is no direct live connection between the client side and server side, because HTTP is a stateless connetion type.

Unlesss you use something like ActiveX, or Java applet, the only way you can communicate between the client and server sides are doing the form posting.
Alone this line, you can call form.submit() method in your timer method and activate the server side methods.

Jianjun
"Borr" <an*******@disc ussions.microso ft.com> wrote in message
news:05******** *************** *****@phx.gbl.. .
Hi,

I have an ASP .NET page, that runs client side timer that
does something on the Server side and after that loads
another page. So I have on client side something like :

function OnPageLoad()
{
setTimeout("OnT imer()", 10000);
}

function OnTimer()
{
ServerMethod();
}

<body onload="OnPageL oad()">
<form id="Form1" method="post" runat="server">

It does not work, and I understand why - client side does
not know what is ServerMethod();

How to call server side method from the timer callback ?
Meanwhile I found workaround : created in Form1 tiny
disabled button DummyBtn "runat=serv er", defined such
server-side event handler for click :

void DummyBtn_Server Click(object obj,EventArgs e)
{
ServerMethod();
}

and on the client side in OnTimer method wrote

Form1.DummyBtn. click();

So the timer simulates click of DummyBtn, click runs its
event handler, the event handler in turn calls the server
method.

It works, but it is ugly solution. I 'd like to call
ServerMethod() from the timer callback directly, without
tricks like this. Is it possible ?


Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
12436
by: HarveyB | last post by:
I would like to generate non-modal popup windows from ASP.Net code-behind. I have tried using Client Side scripting like "function Test(){ window.open('test.htm',_blank, 'height=200,width=400,status=no,toolbar=no, menubar=no,location=no resizable=no scrollable=no'); but I can't seem to invoke the client side script from within a Server Side Form. I know I can use the context with to Response.redirect or Server.transfer to return a
39
6570
by: Randell D. | last post by:
Folks, I'm sure this can be done legally, and not thru tricks of the trade - I hope someone can help. I'm writing a 'tool' (a function) which can be used generically in any of my projects. When it completes, it can call a success, or a failure function. The names of these success, or failure functions will differ, and I'd like to know how I can pass the name of a function to my tool, and how my tool can call the function, using that...
4
1806
by: Bonato Pierantonio | last post by:
Hi All, It is possible inside a SCRIPT tag in the HTML page to call a SUB or FUNCTION write in the codebehind ? Example in the HTML <SCRIPT Language=vbscript> sub mySub call mySecondSub end sub </SCRIPT>
4
3910
by: abcd | last post by:
I am novice asp.net programmer. I have xyz.js file which has resuable functions. I have asp.net form abcd.aspx and the code behind file abcd.aspx.cs, I want to put a 'Help' button when clicked it will open a window and open the required file for me. I am have issues 1.I tried calling my xyz.js function i.e. ShowHelp in the call like in my
1
1618
by: Mr Bojangles | last post by:
Hi, I want a do the following: From a (client side) web form, post to server side script (I'm using Javascript but anything will do), which in turn--and this is the important bit that I can't find out how to do--calls a webservice on a separate server... Client ASP server (no .net)
11
8947
by: rgintexas | last post by:
i'm trying to get server side vbscript to execute in firefox: </script> <script type="text/VBScript" src="VBFile.vbs"> </script> is there any way i can use javascript to call the vbs file, or is there any other method for getting server side vbscript to execute within firefox?
0
1777
by: Werner Willemsens | last post by:
Hi, I have the following situation. COM server exposed on Windows CE 5.0 through SOAP (SOAP toolkit) C# client on XP calls Web Service methods on CE (COM)SOAP server. The complete call takes 527msec. Why is it so much? The SOAP method call is very simple : a COM method with 1 argument (long) The Ethereal logging shows that the CE server side responsiveness is good, but the XP C# client waits a very long time before he gives an ack on...
1
20649
by: Ryan Liu | last post by:
Hi, I have a 100 clients/ one server application, use ugly one thread pre client approach. And both side user sync I/O. I frequently see the error on server side(client side code is same, but I don't see the error): "System.IO.IOException: Unable to read data from the transport connection:A blocking operation was interrupted by a call to WSACancelBlockingCall"
5
2165
by: Simon | last post by:
I heard that we could do that by using AJAX. Could anybody share how to do it? Thanks.
0
9599
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10624
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10371
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10111
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9193
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7650
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5684
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.