通过回复于服务器控件 [英] Server Controls via Response.Write

查看:86
本文介绍了通过回复于服务器控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从ashx的处理程序文件编写HTML的块到.aspx页。在处理程序文件,我想写一个服务器标记

I am trying to write chunks of html to a .aspx page from a .ashx handler file. In the handler file, I am trying to write a server tag

<asp:updatepanel id="UpdatePanel6" childrenastriggers="True" updatemode="Always" runat="server">
<contenttemplate>
<ajaxtoolkit:rating id="Rating6" autopostback="True" emptystarcssclass="Empty" filledstarcssclass="Filled" waitingstarcssclass="Saved" starcssclass="ratingItem" cssclass="ratingStar" currentrating="2" maxrating="5" runat="server"> </ajaxtoolkit:rating>
</contenttemplate>
</asp:updatepanel>

但是,这是不对应.aspx页上显示。当我在Firebug检查它,我看到了code块存在,而不是执行件,它应该是这样

But this is not displayed on the corresponding .aspx page. When I inspect it in firebug, I see the code chunk there rather than the executed piece which should be something like

 <div id="UpdatePanel11">
<div id="Rating11" class="ratingStar">
<input id="Rating11_RatingExtender_ClientState" type="hidden" value="2" name="Rating11_RatingExtender_ClientState">
<a id="Rating11_A" style="text-decoration:none" title="2" href="javascript:void(0)">
<span id="Rating11_Star_1" class="ratingItem Filled" style="float:left;">&nbsp;</span>
<span id="Rating11_Star_2" class="ratingItem Filled" style="float:left;">&nbsp;</span>
<span id="Rating11_Star_3" class="ratingItem Empty" style="float:left;">&nbsp;</span>
<span id="Rating11_Star_4" class="ratingItem Empty" style="float:left;">&nbsp;</span>
<span id="Rating11_Star_5" class="ratingItem Empty" style="float:left;">&nbsp;</span>
</a>
</div>

有人能帮助我什么,我在这里失踪的指针?谢谢 !
    

Could someone help me with pointers on what I am missing here ? Thanks !

推荐答案

您不能做到这一点。回复于直接喷射到输出流中,不经任何处理。一个.aspx页面通过建立一个控制树(包括文字标记,并在.aspx文件中控制标签),并可能在code动态地添加更多的控件生成它的输出。然后树的节点自上而下顺序生成HTML,他们通过电话的Response.Write发送回浏览器进行评估。

You can't do this. Response.Write injects directly into the output stream, without any processing. An .aspx page generates its output by building a control tree (consisting of the literal markup and the control tags in the .aspx file), and possibly adding more controls dynamically in code. Then the nodes of the tree are evaluated in top-down order to generate the HTML, which they send back to the browser through Response.Write calls.

与.aspx页,一个.ashx的处理不处理控制 - 没有控件树。你是负责读取请求,并产生原始响应文本自己。

Unlike an .aspx page, an .ashx handler does not deal with controls -- there is no control tree. You are responsible for reading the request and producing the raw response text yourself.

这听起来像你想创建动态控制;在这种情况下,使用一个.aspx文件,并在codebehind文件添加控件树。

It sounds like you're trying to dynamically create controls; in that case, use an .aspx file and add controls to the tree in the codebehind file.

这篇关于通过回复于服务器控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆