Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How do I force a page to postback continually?

Reply
Thread Tools

How do I force a page to postback continually?

 
 
CW
Guest
Posts: n/a
 
      10-10-2004
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="javascriptoIt(<%=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




 
Reply With Quote
 
 
 
 
Shiva
Guest
Posts: n/a
 
      10-10-2004
Hi,

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

"CW" <> wrote in message
news:#...
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="javascriptoIt(<%=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





 
Reply With Quote
 
 
 
 
CW
Guest
Posts: n/a
 
      10-10-2004
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" <> wrote in message
news:...
> Hi,
>
> Is the form name Form1? Try (irrsepctive of the form name): setTimeout
> ("window.document.forms[0].submit();", 2000);
>
> "CW" <> wrote in message
> news:#...
> 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="javascriptoIt(<%=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
>
>
>
>
>



 
Reply With Quote
 
Shiva
Guest
Posts: n/a
 
      10-10-2004
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" <> wrote in message
news:#...
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" <> wrote in message
news:...
> Hi,
>
> Is the form name Form1? Try (irrsepctive of the form name): setTimeout
> ("window.document.forms[0].submit();", 2000);
>
> "CW" <> wrote in message
> news:#...
> 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="javascriptoIt(<%=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
>
>
>
>
>




 
Reply With Quote
 
CW
Guest
Posts: n/a
 
      10-10-2004
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" <> wrote in message
news:%...
> 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" <> wrote in message
> news:#...
> 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" <> wrote in message
> news:...
>> Hi,
>>
>> Is the form name Form1? Try (irrsepctive of the form name): setTimeout
>> ("window.document.forms[0].submit();", 2000);
>>
>> "CW" <> wrote in message
>> news:#...
>> 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="javascriptoIt(<%=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
>>
>>
>>
>>
>>

>
>
>



 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      10-11-2004
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.)




 
Reply With Quote
 
Shiva
Guest
Posts: n/a
 
      10-11-2004
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" <> wrote in message
news:ex4T#...
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" <> wrote in message
news:%...
> 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" <> wrote in message
> news:#...
> 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" <> wrote in message
> news:...
>> Hi,
>>
>> Is the form name Form1? Try (irrsepctive of the form name): setTimeout
>> ("window.document.forms[0].submit();", 2000);
>>
>> "CW" <> wrote in message
>> news:#...
>> 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="javascriptoIt(<%=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
>>
>>
>>
>>
>>

>
>
>




 
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
Nike air force one, air force 1, air force one low cut, air force one salewholeta@163.com Digital Photography 3 12-31-2008 04:29 PM
Nike Air Force Ones,Air Force One Air Force One-1 lky52193@gmail.com Computer Support 0 01-17-2008 04:40 PM
Nike Air Force Ones,Air Force One Air Force One-1,25th anniversary lky52112@gmail.com Digital Photography 0 01-15-2008 04:46 PM
Nike Air Force Ones,Air Force One Air Force One-1,25th anniversary lky52112@gmail.com Digital Photography 0 01-15-2008 04:34 PM
If SmartNavigation=True, how can I force after PostBack to go on top of the page? Andreas Klemt ASP .Net 1 04-04-2004 03:28 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57