I have a module where in I will select a room and when a user clicks the compare button it will display a lightbox that shows the amenities of each room.
What I did is to create an xslt that list all the rooms and then use a html checkbox. This is my xslt sample.
Have you tried the following, you will probably not need the 1st line to find the control because you look like you have it otherwise it would return null:
Yes I did try that. But still can't find the checkbox control. I guess I need to use javascript for this one and do a response redirect to get the checbox values.
Btw, is it possible to filter the node values from xslt?
to me, your and Tims approach cannot work, since you cannot create server controls within your xslt macro. For that, the output of the xslt would require to be parsed by ASP.NET again, and that AFAIK is not the case. That means that the xslt result will render the runat attribute straight to the client.
I tried that here, but with the xslt snippet you supplied, the id attribute of the checkbox equals "txt", not "txt1110" (so I used Request.Form["txt"] to determine if it is checked -- if it is not there, it is not checked). So have you checked the output for that?
I think your right with this one. I was wondering if the runat="server" tag would just be rendered and the control not actually inserted to the ControlCollection.
Sherry can you show me the source of the checkbox that is rendered? As mentioned above this would answer my question here.
html controls in xslt
Hi Guys,
I have a module where in I will select a room and when a user clicks the compare button it will display a lightbox that shows the amenities of each room.
What I did is to create an xslt that list all the rooms and then use a html checkbox. This is my xslt sample.
<td>
<xsl:choose>
<xsl:when test="floorPlan != ''">
<xsl:variable name="media" select="umbraco.library:GetMedia(floorPlan, 0)" />
<a class="preview" href="{$media/umbracoFile}" title="{@nodeName}">View</a>
</xsl:when>
<xsl:otherwise>
-
</xsl:otherwise>
</xsl:choose>
</td>
<td><input name="txt{@id}" type="checkbox" id="txt{@id}" title="{@nodeName}" runat="server"/></td>
On my room template I put a imagebutton control for the compare button.
<asp:ImageButton id="imgSubmit" ImageUrl="../media/images/general/comparerooms.gif" Width="95" Height="18" runat="server" onclick="imgSubmit_Click"/>
Then put this code at the top of my page.
<script runat="server">
protected void imgSubmit_Click(object sender, ImageClickEventArgs e)
{
Response.Write(txt1110.Value);
}
</script>
I was hardcoding the checkbox id to determine if I'll get the right value. But the code is not working it says that
it says that the current name 'txt1110' does not exists in the current context.
What is wrong in it? why is the xslt did not recognize the runat server that I put on the checbox control?
I guess you could retrieve the input's value using Request.Form['txt1110'].
I've tried that. Though it doesn't produce any errors but it doesn't return any values.
It seems that it can't find the checkbox control.
Have you tried the following, you will probably not need the 1st line to find the control because you look like you have it otherwise it would return null:
CheckBox chk1110 = (CheckBox)Page.FindControl("txt1110");
Use the Checked property rather than value
chk1110.Checked
if this fails just check through the chk1110.Attributes and print them out using something like:
Let me know how you get on.
Thanks, Tim
Hey Tim,
Yes I did try that. But still can't find the checkbox control. I guess I need to use javascript for this one and do a response redirect to get the checbox values.
Btw, is it possible to filter the node values from xslt?
Hi Sherry,
to me, your and Tims approach cannot work, since you cannot create server controls within your xslt macro. For that, the output of the xslt would require to be parsed by ASP.NET again, and that AFAIK is not the case. That means that the xslt result will render the runat attribute straight to the client.
I tried that here, but with the xslt snippet you supplied, the id attribute of the checkbox equals "txt", not "txt1110" (so I used Request.Form["txt"] to determine if it is checked -- if it is not there, it is not checked). So have you checked the output for that?
Atze
What do you mean by "filter the the node values from xslt"? Like including/excluding nodes, that do have certain values?
Hi Atze,
I think your right with this one. I was wondering if the runat="server" tag would just be rendered and the control not actually inserted to the ControlCollection.
Sherry can you show me the source of the checkbox that is rendered? As mentioned above this would answer my question here.
is working on a reply...