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

How do I force a page to postback continually?

CW
I have written a chat console using DHTML/ASPX. One of the hidden frame
continuously refreshes and writes any new messages to a conversation
transcript frame. My problem is that I need to keep track of the last
message I have already written to the transcript frame, thus postback is
necessary (so that LastMessageID stored in the text property of a label
field can be read).

I have the following at <body> tag

<body onload="javascript:DoIt(<%=GetNewMessages()%>)"
MS_POSITIONING="FlowLayout">

where DoIt has the following definition

function DoIt(NewMessages)
{
top.ActualTranscript.document.write(NewMessages);
top.ActualTranscript.window.scrollTo(0,5000000);
setTimeout('Form1.submit',2000)
}
The idea is that the page posts back to itself every 2 seconds. However,
Form1.submit is actually not triggering anything at all. I don't exactly
know much about javascript. I would appreciate some help to get this to
work.

Thanks in advance


Nov 18 '05 #1
6 1699
Hi,

Is the form name Form1? Try (irrsepctive of the form name): setTimeout
("window.document.forms[0].submit();", 2000);

"CW" <CW@nospam.com> wrote in message
news:#G**************@TK2MSFTNGP12.phx.gbl...
I have written a chat console using DHTML/ASPX. One of the hidden frame
continuously refreshes and writes any new messages to a conversation
transcript frame. My problem is that I need to keep track of the last
message I have already written to the transcript frame, thus postback is
necessary (so that LastMessageID stored in the text property of a label
field can be read).

I have the following at <body> tag

<body onload="javascript:DoIt(<%=GetNewMessages()%>)"
MS_POSITIONING="FlowLayout">

where DoIt has the following definition

function DoIt(NewMessages)
{
top.ActualTranscript.document.write(NewMessages);
top.ActualTranscript.window.scrollTo(0,5000000);
setTimeout('Form1.submit',2000)
}
The idea is that the page posts back to itself every 2 seconds. However,
Form1.submit is actually not triggering anything at all. I don't exactly
know much about javascript. I would appreciate some help to get this to
work.

Thanks in advance

Nov 18 '05 #2
CW
Thanks, I have tried that without any success. Form1 is the correct name
because intellisense was able to display a list of methods (including
submit) as I typed it in in the javascript block.
"Shiva" <sh******@online.excite.com> wrote in message
news:eN**************@tk2msftngp13.phx.gbl...
Hi,

Is the form name Form1? Try (irrsepctive of the form name): setTimeout
("window.document.forms[0].submit();", 2000);

"CW" <CW@nospam.com> wrote in message
news:#G**************@TK2MSFTNGP12.phx.gbl...
I have written a chat console using DHTML/ASPX. One of the hidden frame
continuously refreshes and writes any new messages to a conversation
transcript frame. My problem is that I need to keep track of the last
message I have already written to the transcript frame, thus postback is
necessary (so that LastMessageID stored in the text property of a label
field can be read).

I have the following at <body> tag

<body onload="javascript:DoIt(<%=GetNewMessages()%>)"
MS_POSITIONING="FlowLayout">

where DoIt has the following definition

function DoIt(NewMessages)
{
top.ActualTranscript.document.write(NewMessages);
top.ActualTranscript.window.scrollTo(0,5000000);
setTimeout('Form1.submit',2000)
}
The idea is that the page posts back to itself every 2 seconds. However,
Form1.submit is actually not triggering anything at all. I don't exactly
know much about javascript. I would appreciate some help to get this to
work.

Thanks in advance


Nov 18 '05 #3
Hi,
Make sure the first two lines in DoIt() do not produce any script errors. As
a quick check comment-out the first two lines and check the form is
submited. Also have () after submit as it is a method.

"CW" <CW@nospam.com> wrote in message
news:#n**************@TK2MSFTNGP14.phx.gbl...
Thanks, I have tried that without any success. Form1 is the correct name
because intellisense was able to display a list of methods (including
submit) as I typed it in in the javascript block.
"Shiva" <sh******@online.excite.com> wrote in message
news:eN**************@tk2msftngp13.phx.gbl...
Hi,

Is the form name Form1? Try (irrsepctive of the form name): setTimeout
("window.document.forms[0].submit();", 2000);

"CW" <CW@nospam.com> wrote in message
news:#G**************@TK2MSFTNGP12.phx.gbl...
I have written a chat console using DHTML/ASPX. One of the hidden frame
continuously refreshes and writes any new messages to a conversation
transcript frame. My problem is that I need to keep track of the last
message I have already written to the transcript frame, thus postback is
necessary (so that LastMessageID stored in the text property of a label
field can be read).

I have the following at <body> tag

<body onload="javascript:DoIt(<%=GetNewMessages()%>)"
MS_POSITIONING="FlowLayout">

where DoIt has the following definition

function DoIt(NewMessages)
{
top.ActualTranscript.document.write(NewMessages);
top.ActualTranscript.window.scrollTo(0,5000000);
setTimeout('Form1.submit',2000)
}
The idea is that the page posts back to itself every 2 seconds. However,
Form1.submit is actually not triggering anything at all. I don't exactly
know much about javascript. I would appreciate some help to get this to
work.

Thanks in advance



Nov 18 '05 #4
CW
I got the form to resubmit by putting Form1.submit after the body
tagaltogether.

DoIt block is defined in <header> tag in a script block. After i removed the
submit statement and put it in its own script block that comes after body
tag altogether, form is now resubmitting.

However, it's not picking up a textbox text property value when it
resubmits. The page and control has viewstate enabled. I think it might have
someting to do with passing __VIEWSTATE in the javascript. Any idea how to
achieve that?

thanks

"Shiva" <sh******@online.excite.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,
Make sure the first two lines in DoIt() do not produce any script errors.
As
a quick check comment-out the first two lines and check the form is
submited. Also have () after submit as it is a method.

"CW" <CW@nospam.com> wrote in message
news:#n**************@TK2MSFTNGP14.phx.gbl...
Thanks, I have tried that without any success. Form1 is the correct name
because intellisense was able to display a list of methods (including
submit) as I typed it in in the javascript block.
"Shiva" <sh******@online.excite.com> wrote in message
news:eN**************@tk2msftngp13.phx.gbl...
Hi,

Is the form name Form1? Try (irrsepctive of the form name): setTimeout
("window.document.forms[0].submit();", 2000);

"CW" <CW@nospam.com> wrote in message
news:#G**************@TK2MSFTNGP12.phx.gbl...
I have written a chat console using DHTML/ASPX. One of the hidden frame
continuously refreshes and writes any new messages to a conversation
transcript frame. My problem is that I need to keep track of the last
message I have already written to the transcript frame, thus postback is
necessary (so that LastMessageID stored in the text property of a label
field can be read).

I have the following at <body> tag

<body onload="javascript:DoIt(<%=GetNewMessages()%>)"
MS_POSITIONING="FlowLayout">

where DoIt has the following definition

function DoIt(NewMessages)
{
top.ActualTranscript.document.write(NewMessages);
top.ActualTranscript.window.scrollTo(0,5000000);
setTimeout('Form1.submit',2000)
}
The idea is that the page posts back to itself every 2 seconds. However,
Form1.submit is actually not triggering anything at all. I don't exactly
know much about javascript. I would appreciate some help to get this to
work.

Thanks in advance



Nov 18 '05 #5
Hi CW,

AS for getting the new posted value in the textbox , here are some of my
suggestions:

Are you using the asp.net's TextBox server control or the HtmlInputText
control or
a normal <input type=text...> html element ? Anyway, we don't need to
manually post back the viewstate

I think we can check the following things:

1.If you're using the TExtBox server control <asp:TextBox ..> or
HtmlInputText control
<input type=text runat=server...>
we can directly access it via
id in the serverside code behind

2. if he is using normal <input type=text ...> html element, we can
access it's new postd value in the Request.Form collection
for example , if we have the following textbox in th form,

<input type=text name="username" >

Then,when the page is post back, we can use the Request.Form["username"] to
get its value.
#note that request.Form collection will identify the different items via
their "name" attribute in the html

In addition, make sure that the TextBox or <input type=text ..> are within
the <form > tag. And here is a simple test page which put some textboxes on
it and access their value when post back , you may also have a test:

=========aspx page=======================
<HTML>
<HEAD>
<title>postbackscript</title>
<script language="javascript">
function autopost()
{
window.setTimeout("document.forms[0].submit()",2000);
}
</script>
</HEAD>
<body onload="autopost();">
<form id="Form1" method="post" runat="server">
<table width="100%" align="center">
<tr>
<td height="21">
<asp:TextBox id="txtServer" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td><INPUT id="txtInputText" type="text" size="1" name="txtInputText"
runat="server"></td>
</tr>
<tr>
<td><INPUT id="txtNormalInput" type="text" name="txtNormalInput"></td>
</tr>
</table>
</form>
</body>
</HTML>

===============code behind==========================
public class postbackscript : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox txtServer;
protected System.Web.UI.HtmlControls.HtmlInputText txtInputText;

private void Page_Load(object sender, System.EventArgs e)
{
if(IsPostBack)
{
Response.Write("<br>Page is post back at: " +
DateTime.Now.ToLongTimeString());
Response.Write("<br>txtServer's post value is: " + txtServer.Text);
Response.Write("<br>txtInputText's post value is: " +
txtInputText.Value);
Response.Write("<br>txtNormalInput's post value is: " +
Request.Form["txtNormalInput"]);
}
}
.................................

}

==================================
Hope helps. If you still have anything unclear, please feel free to post
here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Nov 18 '05 #6
Hi,

Is the textbox a server-side control (runat=server) or is it not? As Steven
suggested, based on how you have defined your text box, you have to use
either Request.Form collection or refer to the textbox directly to get the
text value.

HTH

"CW" <CW@nospam.com> wrote in message
news:ex**************@TK2MSFTNGP10.phx.gbl...
I got the form to resubmit by putting Form1.submit after the body
tagaltogether.

DoIt block is defined in <header> tag in a script block. After i removed the
submit statement and put it in its own script block that comes after body
tag altogether, form is now resubmitting.

However, it's not picking up a textbox text property value when it
resubmits. The page and control has viewstate enabled. I think it might have
someting to do with passing __VIEWSTATE in the javascript. Any idea how to
achieve that?

thanks

"Shiva" <sh******@online.excite.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,
Make sure the first two lines in DoIt() do not produce any script errors.
As
a quick check comment-out the first two lines and check the form is
submited. Also have () after submit as it is a method.

"CW" <CW@nospam.com> wrote in message
news:#n**************@TK2MSFTNGP14.phx.gbl...
Thanks, I have tried that without any success. Form1 is the correct name
because intellisense was able to display a list of methods (including
submit) as I typed it in in the javascript block.
"Shiva" <sh******@online.excite.com> wrote in message
news:eN**************@tk2msftngp13.phx.gbl...
Hi,

Is the form name Form1? Try (irrsepctive of the form name): setTimeout
("window.document.forms[0].submit();", 2000);

"CW" <CW@nospam.com> wrote in message
news:#G**************@TK2MSFTNGP12.phx.gbl...
I have written a chat console using DHTML/ASPX. One of the hidden frame
continuously refreshes and writes any new messages to a conversation
transcript frame. My problem is that I need to keep track of the last
message I have already written to the transcript frame, thus postback is
necessary (so that LastMessageID stored in the text property of a label
field can be read).

I have the following at <body> tag

<body onload="javascript:DoIt(<%=GetNewMessages()%>)"
MS_POSITIONING="FlowLayout">

where DoIt has the following definition

function DoIt(NewMessages)
{
top.ActualTranscript.document.write(NewMessages);
top.ActualTranscript.window.scrollTo(0,5000000);
setTimeout('Form1.submit',2000)
}
The idea is that the page posts back to itself every 2 seconds. However,
Form1.submit is actually not triggering anything at all. I don't exactly
know much about javascript. I would appreciate some help to get this to
work.

Thanks in advance




Nov 18 '05 #7

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

Similar topics

1
by: Pamela Chatterjee | last post by:
In my project I am uploading file using File control. After browsing file user needs to select other values from DropdownList to determine uploading path. After selection in couple of drop down...
4
by: Tom | last post by:
Does anyone know how ot force a postback in the codebehind? Thanks Tom
1
by: Julie Barnet | last post by:
I would like to be able to force a postback when a user tabs off of a user control. I currently have the following code: <script language="JavaScript1.1"><!-- function keyPressed() {...
1
by: Andreas Klemt | last post by:
Hello, when SmartNavigation is True how can I force after Postback that the page goes to the top because of the error message or where should I put the error message (top or button)? With old...
5
by: Jeronimo Bertran | last post by:
I have a DataGrid that gets filled based on a filter which is defined by the values that the user selects on several controls. When the page postbacks after changing the selection on the filter...
10
by: Nathan Sokalski | last post by:
One thing that I have often needed to do that I have been unable to find a way to do is refresh the page (basically do the same thing as pressing the browser's Refresh button). I know how to do...
2
by: Byron Hopp [MCS] | last post by:
How do you force a postback, we have a button to save our users entry, but the button does not have a postback property (like the dropdownlistbox). Is there a way to force a postback? Byron...
6
by: Shawn | last post by:
Any ideas how I can have a button click on one open page force a postback on a different page.
1
by: =?Utf-8?B?QnJ5YW4=?= | last post by:
Is there a way to force a "traditional" full page postback in AJAX? I have a page with multiple UpdatePanels and I usually call UpdatePanel.Update() to do a partial postback, but I have one...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
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...

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.