Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sherry Ann Hernandez 320 posts 344 karma points
    Nov 08, 2010 @ 14:33
    Sherry Ann Hernandez
    0

    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?

  • atze187 160 posts 215 karma points
    Nov 08, 2010 @ 14:39
    atze187
    0

    I guess you could retrieve the input's value using Request.Form['txt1110'].

  • Sherry Ann Hernandez 320 posts 344 karma points
    Nov 08, 2010 @ 14:56
    Sherry Ann Hernandez
    0

    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.

  • Powellze 38 posts 73 karma points
    Nov 09, 2010 @ 11:17
    Powellze
    0

    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:

    foreach(string strAttribute in chk1110.Attributes){
    Response.Write("Attribute name: " + strAttribute + "<br />");
    Response.Write("Attribute value: " + chk1110.Attributes[strAttribute] + "<br />");
    }

    Let me know how you get on.

     

    Thanks, Tim

  • Sherry Ann Hernandez 320 posts 344 karma points
    Nov 10, 2010 @ 08:41
    Sherry Ann Hernandez
    0

    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?

  • atze187 160 posts 215 karma points
    Nov 10, 2010 @ 08:58
    atze187
    0

    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


  • atze187 160 posts 215 karma points
    Nov 10, 2010 @ 09:00
    atze187
    0

    What do you mean by "filter the the node values from xslt"? Like including/excluding nodes, that do have certain values?

  • Powellze 38 posts 73 karma points
    Nov 10, 2010 @ 11:55
    Powellze
    0

    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.

Please Sign in or register to post replies

Write your reply to:

Draft