[英]Response.Write() in Umbraco user control clears all page content
我正在使用以下代碼將表添加到Umbraco中的用戶控件。
Try
Dim DS As DataSet = GetData()
If DS.Tables(0).Rows.Count > 0 Then
Response.Write("<form><table>")
For Each row In DS.Tables(0).Rows
Response.Write("<tr>")
Response.Write("<td> <a onclick=alert('" & row("ID") & "')>" & row("Date") & "</a></td>")
Response.Write("<td>" & " - " & "</td>")
Response.Write("<td>" & row("Amount") & "</td>")
Response.Write("</tr>")
Next
Response.Write("</table></form>")
Response.End()
End If
Catch ex As Exception
Response.End()
End Try
但是,在循環完成之后會發生什么(沒有錯誤-我已逐步完成整個過程),頁面上剩下的唯一內容是表格。
我確定我確實遺漏了一些愚蠢的東西。 有什么幫助嗎?
謝謝!
在這種情況下, Response.Write()
不應該受到指責,這是您的Response.End()
調用。 它不會清除其余頁面內容,但實際上阻止了它的運行。
HttpResponse.End方法
將所有當前緩沖的輸出發送到客戶端,停止頁面的執行,並引發EndRequest事件。
http://msdn.microsoft.com/zh-CN/library/system.web.httpresponse.end.aspx
刪除它們(如果想要使用catch語句中的一個,則至少刪除try塊中的一個),這應該為您解決。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.