Reputation: 657
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>
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;"> </span>
<span id="Rating11_Star_2" class="ratingItem Filled" style="float:left;"> </span>
<span id="Rating11_Star_3" class="ratingItem Empty" style="float:left;"> </span>
<span id="Rating11_Star_4" class="ratingItem Empty" style="float:left;"> </span>
<span id="Rating11_Star_5" class="ratingItem Empty" style="float:left;"> </span>
</a>
</div>
Could someone help me with pointers on what I am missing here ? Thanks !
Upvotes: 1
Views: 1313
Reputation: 17370
as Carl mentioned this is going to be a little hard to accomplish. If what you need to do is just to create a dynamic Rating thing, I would suggest to use page.Controls.Add
and add handlers to them so that they can handle when an user clicks on them. If you need help please let us know.
Upvotes: 0
Reputation: 4479
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.
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.
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.
Upvotes: 2