RESPONSE.WRITE和ASP.NET控件 [英] Response.write and ASP.NET controls
问题描述
请参阅下面的code:
Please see the code below:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Response.Write("<table><tr><td>some text</td></tr></table>")
Response.Flush()
Threading.Thread.Sleep(3000)
Response.Write("<table><tr><td>some text</td></tr></table>")
Response.Flush()
Threading.Thread.Sleep(3000)
Response.Write("<table><tr><td>some text</td></tr></table>")
Response.Flush()
Threading.Thread.Sleep(3000)
Response.Write("<table><tr><td>some text</td></tr></table>")
Response.Flush()
Threading.Thread.Sleep(3000)
End Sub
的code工程,我期望即产生一个HTML表格并写入到屏幕上,然后在三秒钟后,产生另一个表,并加入到画面等。
The code works as I would expect i.e. a HTML table is generated and written to the screen, then after three seconds another table is generated and added to the screen etc.
我有一个网页动态地将表中的x个(的http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.table%28v=vs.110%29.aspx) 。到网页然而,Response.Flush似乎并没有工作,我已经创建了下面的简单code来解释这个问题:
I have a webpage that dynamically adds x number of tables (http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.table%28v=vs.110%29.aspx) to a webpage. However, Response.Flush does not seem to work. I have created the simple code below to explain the problem:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim Table1 As New Table
Dim r As New TableRow()
Dim c As New TableCell()
c.Text = "Test 1"
r.Cells.Add(c)
Table1.Rows.Add(r)
Response.Flush()
Threading.Thread.Sleep(3000)
Dim Table2 As New Table
Dim r2 As New TableRow()
Dim c2 As New TableCell()
c.Text = "Test 2"
r.Cells.Add(c)
Table1.Rows.Add(r)
End Sub
是否有可能刷新表1到客户端,然后等待几秒钟,然后冲水表2或你有写一个字符串RESPONSE.WRITE?
Is it possible to flush table1 to the client, then wait a few seconds then flush table2 or do you have to write a string to response.write?
推荐答案
要使用 Response.Flush
以这种方式,你需要输出所有的HTML code自己使用的Response.Write
。
To use Response.Flush
in that way you need to output all the HTML code yourself using Response.Write
.
您不能使用网络的控制,因为它们没有渲染,直到页面完成。该网站只控制存在的对象,直到那里的整个页面呈现为HTML code,然后发送给浏览器的 Page_Render
阶段。
You can't use web controls as they are not rendered until the page is complete. The web controls only exist as objects until the Page_Render
stage where the entire page is rendered as HTML code and then sent to the browser.
这篇关于RESPONSE.WRITE和ASP.NET控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!