[英]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.