473,395 Members | 1,568 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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("OnTimer()", 10000);
}

function OnTimer()
{
ServerMethod();
}

<body onload="OnPageLoad()">
<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=server", defined such
server-side event handler for click :

void DummyBtn_ServerClick(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 6908
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*******@discussions.microsoft.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("OnTimer()", 10000);
}

function OnTimer()
{
ServerMethod();
}

<body onload="OnPageLoad()">
<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=server", defined such
server-side event handler for click :

void DummyBtn_ServerClick(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*******@discussions.microsoft.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("OnTimer()", 10000);
}

function OnTimer()
{
ServerMethod();
}

<body onload="OnPageLoad()">
<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=server", defined such
server-side event handler for click :

void DummyBtn_ServerClick(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*******@yahoo.com> wrote in message
news:q9********************@comcast.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*******@discussions.microsoft.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("OnTimer()", 10000);
}

function OnTimer()
{
ServerMethod();
}

<body onload="OnPageLoad()">
<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=server", defined such
server-side event handler for click :

void DummyBtn_ServerClick(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
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,...
39
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. ...
4
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...
4
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...
1
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...
11
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...
0
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...
1
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...
5
by: Simon | last post by:
I heard that we could do that by using AJAX. Could anybody share how to do it? Thanks.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
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,...

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.