473,408 Members | 2,832 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,408 software developers and data experts.

ASP.NET Question

How do I make PostBack Call from the Server so that I can update something on the client web browser? The Client just has the page open theres is no event from the Client. But I want to push something from the server so that the client webpage reloads with the new information. Code Sample Please

Shreyash
Nov 18 '05 #1
9 1715
nope....
http is Request/Response... not push based.
--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com
"Shreyash Patel" <an*******@discussions.microsoft.com> wrote in message
news:0B**********************************@microsof t.com...
How do I make PostBack Call from the Server so that I can update something on the client web browser? The Client just has the page open theres is no
event from the Client. But I want to push something from the server so that
the client webpage reloads with the new information. Code Sample Please?
Shreyash

Nov 18 '05 #2
Then ASP.NET Chat would never be possible. The ASP.NET for Dummies has a implementation of a Chat Room Applicaiton created just using ASP.NET. There must be some way of forcing the client page to refresh or update.
Nov 18 '05 #3
We have something similar on our site. check out
www.myfloridahouse.com/session_live_preview.aspx. We have to update
information to the user every 60 seconds so the user knows if the House is
dicussing another bill and/or amendment. We achived this by setting an
autopost back every 60 seconds with the following code:

private void RegisterRefreshScript()
{
// register a script to auto post back every so many seconds
// NOTE: Setting a meta tag to refresh will not do a (POST BACK)
int refreshRate =
Convert.ToInt32(ConfigurationSettings.AppSettings["SessionLiveRefreshRate"])
;
StringBuilder scriptBlock = new StringBuilder();
scriptBlock.Append( "<script>" );
scriptBlock.Append( "function sessionLive_autoPostBack() ");
scriptBlock.Append( "{ " );
scriptBlock.Append( " __doPostBack('lnkPostBack','');");
scriptBlock.Append( "} " );
scriptBlock.Append( "window.setInterval( 'sessionLive_autoPostBack()', ");
scriptBlock.Append( refreshRate.ToString() );
scriptBlock.Append( "); ");
scriptBlock.Append( "</script>" );
RegisterStartupScript( "autoPostBack", scriptBlock.ToString() );
}

If you call this function each time there is a postback, you can be assurred
that the brower will post back to the server every so many seconds. Don't
let this confuse you, the lnkPostBack is just a server side link button
declare on the ASPX page like so:

<asp:LinkButton ID="lnkPostBack" Runat="server"></asp:LinkButton>

What is nice is that that when the post back happens it will call the
lnkPostBack_Click event (so long as you have an event for it set up) so you
know the difference between the user clicking the refresh button, other
buttons that may cause a post back, and the registered script block that was
added.

Let me know if this helps you out!

Thanks,
"Shreyash Patel" <an*******@discussions.microsoft.com> wrote in message
news:0B**********************************@microsof t.com...
How do I make PostBack Call from the Server so that I can update something on the client web browser? The Client just has the page open theres is no
event from the Client. But I want to push something from the server so that
the client webpage reloads with the new information. Code Sample Please?
Shreyash

Nov 18 '05 #4
Not really. One way to implement this would be to use either a hidden
frame, or have a page auto-refresh at a given interval (say 10 seconds).
Using session variables (for example) you can track what messages the client
has already seen, and send any news ones.

But you can't do this server side; the key to pulling this off would be to
use some "hack" client side to post/get back.

Brian
"Shreyash Patel" <an*******@discussions.microsoft.com> wrote in message
news:06**********************************@microsof t.com...
Then ASP.NET Chat would never be possible. The ASP.NET for Dummies has a

implementation of a Chat Room Applicaiton created just using ASP.NET. There
must be some way of forcing the client page to refresh or update.
Nov 18 '05 #5
yes, you can force the client to refresh, that's not what you asked though.
you can use a simple meta refresh tag for this even. You asked to have the
SERVER push without a client request.....that's not currently possible
without a component

--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com
"Shreyash Patel" <an*******@discussions.microsoft.com> wrote in message
news:06**********************************@microsof t.com...
Then ASP.NET Chat would never be possible. The ASP.NET for Dummies has a

implementation of a Chat Room Applicaiton created just using ASP.NET. There
must be some way of forcing the client page to refresh or update.
Nov 18 '05 #6
That's great. I can follow everything that you're doing here except for the
line
"RegisterStatupScript("autoPostBack", scriptBlock.ToString() );"

What is this doing? Is this a function name of yours or something that has
special meaning in ASP.Net?

Pitcher

"Jeffrey A. Voigt" <vo***********@myfloridahouse.com> wrote in message
news:Oc**************@TK2MSFTNGP10.phx.gbl...
We have something similar on our site. check out
www.myfloridahouse.com/session_live_preview.aspx. We have to update
information to the user every 60 seconds so the user knows if the House is
dicussing another bill and/or amendment. We achived this by setting an
autopost back every 60 seconds with the following code:

private void RegisterRefreshScript()
{
// register a script to auto post back every so many seconds
// NOTE: Setting a meta tag to refresh will not do a (POST BACK)
int refreshRate =
Convert.ToInt32(ConfigurationSettings.AppSettings["SessionLiveRefreshRate"]) ;
StringBuilder scriptBlock = new StringBuilder();
scriptBlock.Append( "<script>" );
scriptBlock.Append( "function sessionLive_autoPostBack() ");
scriptBlock.Append( "{ " );
scriptBlock.Append( " __doPostBack('lnkPostBack','');");
scriptBlock.Append( "} " );
scriptBlock.Append( "window.setInterval( 'sessionLive_autoPostBack()', "); scriptBlock.Append( refreshRate.ToString() );
scriptBlock.Append( "); ");
scriptBlock.Append( "</script>" );
RegisterStartupScript( "autoPostBack", scriptBlock.ToString() );
}

If you call this function each time there is a postback, you can be assurred that the brower will post back to the server every so many seconds. Don't
let this confuse you, the lnkPostBack is just a server side link button
declare on the ASPX page like so:

<asp:LinkButton ID="lnkPostBack" Runat="server"></asp:LinkButton>

What is nice is that that when the post back happens it will call the
lnkPostBack_Click event (so long as you have an event for it set up) so you know the difference between the user clicking the refresh button, other
buttons that may cause a post back, and the registered script block that was added.

Let me know if this helps you out!

Thanks,
"Shreyash Patel" <an*******@discussions.microsoft.com> wrote in message
news:0B**********************************@microsof t.com...
How do I make PostBack Call from the Server so that I can update
something on the client web browser? The Client just has the page open theres is no
event from the Client. But I want to push something from the server so that the client webpage reloads with the new information. Code Sample Please?

Shreyash


Nov 18 '05 #7
RegisterStartupScript is an ASP.NET function that will add and execute the
script as soon as the client receives the web page. The first param is just
a name you can give the script block. I just chose to use "autoPostBack"
for the name. The second param is the actual script. That was constructed
in the above lines.

Thanks,
- jv

"pitcher17" <sp**@magma.ca> wrote in message
news:K9********************@magma.ca...
That's great. I can follow everything that you're doing here except for the line
"RegisterStatupScript("autoPostBack", scriptBlock.ToString() );"

What is this doing? Is this a function name of yours or something that has special meaning in ASP.Net?

Pitcher

"Jeffrey A. Voigt" <vo***********@myfloridahouse.com> wrote in message
news:Oc**************@TK2MSFTNGP10.phx.gbl...
We have something similar on our site. check out
www.myfloridahouse.com/session_live_preview.aspx. We have to update
information to the user every 60 seconds so the user knows if the House is dicussing another bill and/or amendment. We achived this by setting an
autopost back every 60 seconds with the following code:

private void RegisterRefreshScript()
{
// register a script to auto post back every so many seconds
// NOTE: Setting a meta tag to refresh will not do a (POST BACK)
int refreshRate =

Convert.ToInt32(ConfigurationSettings.AppSettings["SessionLiveRefreshRate"])
;
StringBuilder scriptBlock = new StringBuilder();
scriptBlock.Append( "<script>" );
scriptBlock.Append( "function sessionLive_autoPostBack() ");
scriptBlock.Append( "{ " );
scriptBlock.Append( " __doPostBack('lnkPostBack','');");
scriptBlock.Append( "} " );
scriptBlock.Append( "window.setInterval( 'sessionLive_autoPostBack()',

");
scriptBlock.Append( refreshRate.ToString() );
scriptBlock.Append( "); ");
scriptBlock.Append( "</script>" );
RegisterStartupScript( "autoPostBack", scriptBlock.ToString() );
}

If you call this function each time there is a postback, you can be

assurred
that the brower will post back to the server every so many seconds. Don't let this confuse you, the lnkPostBack is just a server side link button
declare on the ASPX page like so:

<asp:LinkButton ID="lnkPostBack" Runat="server"></asp:LinkButton>

What is nice is that that when the post back happens it will call the
lnkPostBack_Click event (so long as you have an event for it set up) so

you
know the difference between the user clicking the refresh button, other
buttons that may cause a post back, and the registered script block that

was
added.

Let me know if this helps you out!

Thanks,
"Shreyash Patel" <an*******@discussions.microsoft.com> wrote in message
news:0B**********************************@microsof t.com...
How do I make PostBack Call from the Server so that I can update something
on the client web browser? The Client just has the page open theres is

no event from the Client. But I want to push something from the server so

that
the client webpage reloads with the new information. Code Sample Please?

Shreyash



Nov 18 '05 #8

Ok. So, "autoPostBack" is just the name you gave it in order to reference
it later?

thank you.

"Jeffrey A. Voigt" <vo***********@myfloridahouse.com> wrote in message
news:Om**************@TK2MSFTNGP09.phx.gbl...
RegisterStartupScript is an ASP.NET function that will add and execute the
script as soon as the client receives the web page. The first param is just a name you can give the script block. I just chose to use "autoPostBack"
for the name. The second param is the actual script. That was constructed in the above lines.

Thanks,
- jv

"pitcher17" <sp**@magma.ca> wrote in message
news:K9********************@magma.ca...
That's great. I can follow everything that you're doing here except for the
line
"RegisterStatupScript("autoPostBack", scriptBlock.ToString() );"

What is this doing? Is this a function name of yours or something that

has
special meaning in ASP.Net?

Pitcher

"Jeffrey A. Voigt" <vo***********@myfloridahouse.com> wrote in message
news:Oc**************@TK2MSFTNGP10.phx.gbl...
We have something similar on our site. check out
www.myfloridahouse.com/session_live_preview.aspx. We have to update
information to the user every 60 seconds so the user knows if the House is
dicussing another bill and/or amendment. We achived this by setting
an autopost back every 60 seconds with the following code:

private void RegisterRefreshScript()
{
// register a script to auto post back every so many seconds
// NOTE: Setting a meta tag to refresh will not do a (POST BACK)
int refreshRate =

Convert.ToInt32(ConfigurationSettings.AppSettings["SessionLiveRefreshRate"])
;
StringBuilder scriptBlock = new StringBuilder();
scriptBlock.Append( "<script>" );
scriptBlock.Append( "function sessionLive_autoPostBack() ");
scriptBlock.Append( "{ " );
scriptBlock.Append( " __doPostBack('lnkPostBack','');");
scriptBlock.Append( "} " );
scriptBlock.Append( "window.setInterval( 'sessionLive_autoPostBack()',
");
scriptBlock.Append( refreshRate.ToString() );
scriptBlock.Append( "); ");
scriptBlock.Append( "</script>" );
RegisterStartupScript( "autoPostBack", scriptBlock.ToString() );
}

If you call this function each time there is a postback, you can be

assurred
that the brower will post back to the server every so many seconds. Don't let this confuse you, the lnkPostBack is just a server side link
button declare on the ASPX page like so:

<asp:LinkButton ID="lnkPostBack" Runat="server"></asp:LinkButton>

What is nice is that that when the post back happens it will call the
lnkPostBack_Click event (so long as you have an event for it set up) so
you
know the difference between the user clicking the refresh button,
other buttons that may cause a post back, and the registered script block that was
added.

Let me know if this helps you out!

Thanks,
"Shreyash Patel" <an*******@discussions.microsoft.com> wrote in

message news:0B**********************************@microsof t.com...
> How do I make PostBack Call from the Server so that I can update

something
on the client web browser? The Client just has the page open theres is

no event from the Client. But I want to push something from the server so

that
the client webpage reloads with the new information. Code Sample Please? >
> Shreyash



Nov 18 '05 #9
"autoPostBack" is just a name given to the script... you can put in
"blahblahblah" and it would not make a difference. It is not referenced
anywhere, it is just to give meaning to the script block, that's about it :)

Thanks,
- jv

"pitcher17" <sp**@magma.ca> wrote in message
news:oJ********************@magma.ca...

Ok. So, "autoPostBack" is just the name you gave it in order to reference it later?

thank you.

"Jeffrey A. Voigt" <vo***********@myfloridahouse.com> wrote in message
news:Om**************@TK2MSFTNGP09.phx.gbl...
RegisterStartupScript is an ASP.NET function that will add and execute the
script as soon as the client receives the web page. The first param is

just
a name you can give the script block. I just chose to use "autoPostBack" for the name. The second param is the actual script. That was

constructed
in the above lines.

Thanks,
- jv

"pitcher17" <sp**@magma.ca> wrote in message
news:K9********************@magma.ca...
That's great. I can follow everything that you're doing here except for
the
line
"RegisterStatupScript("autoPostBack", scriptBlock.ToString() );"

What is this doing? Is this a function name of yours or something
that has
special meaning in ASP.Net?

Pitcher

"Jeffrey A. Voigt" <vo***********@myfloridahouse.com> wrote in message
news:Oc**************@TK2MSFTNGP10.phx.gbl...
> We have something similar on our site. check out
> www.myfloridahouse.com/session_live_preview.aspx. We have to update
> information to the user every 60 seconds so the user knows if the House
is
> dicussing another bill and/or amendment. We achived this by setting

an > autopost back every 60 seconds with the following code:
>
> private void RegisterRefreshScript()
> {
> // register a script to auto post back every so many seconds
> // NOTE: Setting a meta tag to refresh will not do a (POST BACK)
> int refreshRate =
>

Convert.ToInt32(ConfigurationSettings.AppSettings["SessionLiveRefreshRate"]) > ;
> StringBuilder scriptBlock = new StringBuilder();
> scriptBlock.Append( "<script>" );
> scriptBlock.Append( "function sessionLive_autoPostBack() ");
> scriptBlock.Append( "{ " );
> scriptBlock.Append( " __doPostBack('lnkPostBack','');");
> scriptBlock.Append( "} " );
> scriptBlock.Append( "window.setInterval( 'sessionLive_autoPostBack()', ");
> scriptBlock.Append( refreshRate.ToString() );
> scriptBlock.Append( "); ");
> scriptBlock.Append( "</script>" );
> RegisterStartupScript( "autoPostBack", scriptBlock.ToString() );
> }
>
> If you call this function each time there is a postback, you can be
assurred
> that the brower will post back to the server every so many seconds.

Don't
> let this confuse you, the lnkPostBack is just a server side link button > declare on the ASPX page like so:
>
> <asp:LinkButton ID="lnkPostBack" Runat="server"></asp:LinkButton>
>
> What is nice is that that when the post back happens it will call the > lnkPostBack_Click event (so long as you have an event for it set up) so you
> know the difference between the user clicking the refresh button, other > buttons that may cause a post back, and the registered script block that was
> added.
>
> Let me know if this helps you out!
>
> Thanks,
>
>
> "Shreyash Patel" <an*******@discussions.microsoft.com> wrote in message > news:0B**********************************@microsof t.com...
> > How do I make PostBack Call from the Server so that I can update
something
> on the client web browser? The Client just has the page open theres is no
> event from the Client. But I want to push something from the server
so that
> the client webpage reloads with the new information. Code Sample

Please? > >
> > Shreyash
>
>



Nov 18 '05 #10

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

Similar topics

3
by: Stevey | last post by:
I have the following XML file... <?xml version="1.0"?> <animals> <animal> <name>Tiger</name> <questions> <question index="0">true</question> <question index="1">true</question> </questions>
3
by: Ekqvist Marko | last post by:
Hi, I have one Access database table including questions and answers. Now I need to give answer id automatically to questionID column. But I don't know how it is best (fastest) to do? table...
53
by: Jeff | last post by:
In the function below, can size ever be 0 (zero)? char *clc_strdup(const char * CLC_RESTRICT s) { size_t size; char *p; clc_assert_not_null(clc_strdup, s); size = strlen(s) + 1;
56
by: spibou | last post by:
In the statement "a *= expression" is expression assumed to be parenthesized ? For example if I write "a *= b+c" is this the same as "a = a * (b+c)" or "a = a * b+c" ?
2
by: Allan Ebdrup | last post by:
Hi, I'm trying to render a Matrix question in my ASP.Net 2.0 page, A matrix question is a question where you have several options that can all be rated according to several possible ratings (from...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
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...

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.