Copied to clipboard

Flag this post as spam?

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


  • kukuwka 75 posts 96 karma points
    Sep 06, 2010 @ 10:27
    kukuwka
    0

    Call to xslt extension function only after event

    Hi,

    How can I call to xslt extension function only when I press button.

    I have : <input type="submit"  value="submit"/>

    and only when I click on the button I want to call to function.

    <xsl:value-of select="TestClass:TestFunction(param1, param2)"/>

    Thanks,

    kukuwka

     

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Sep 06, 2010 @ 10:37
    Matt Brailsford
    0

    Hi Kukuwka,

    You could check for a Form variable to see if the page is a postback?

    <xsl:if test="string-length(umbraco.library:RequestForm('submit')) &gt; 0">
    <xsl:value-of select="TestClass:TestFunction(param1, param2)"/>
    </xsl:if>

    Matt

  • kukuwka 75 posts 96 karma points
    Sep 06, 2010 @ 12:30
    kukuwka
    0

    Hi Matt,

    I put this code on my page ,but nothing happens when I click button.

    Maybe I missed something and I need to add something else.

     Thanks,

    kukuwka

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Sep 06, 2010 @ 12:45
    Lee Kelleher
    0

    Hi kukuwka,

    Post up a snippet of your XSLT, so we can see what is missing? (I'm hoping that it's something simple like a <form> tag?)

    Whilst this is possible to do it in XSLT, have you considered moving the functionality to a .NET user-control? It will offer better maintainability in the future. (Trust me, I've done this in XSLT previously, it very very quickly becomes a nightmare to debug/manage).

    Cheers, Lee.

  • Hendrik Jan 71 posts 137 karma points
    Sep 06, 2010 @ 12:57
    Hendrik Jan
    1

     

    Makse sure your form method is post.

    AND Make that: 
     <input type="submit"  NAME="submit" value="submit"/>

  • kukuwka 75 posts 96 karma points
    Sep 06, 2010 @ 13:15
    kukuwka
    0

    This my code:

    <xsl:template match="/"> 
    <!-- start writing XSLT -->      
     <div class="form">         
    <div class="comments-tab">
    <form action="#" method="post" ><div class="form-wrap">
    <ol>
    <li>
    <label for="name">name:</label>
    <input class="input type-text" id="name" type="text"/>
    </li>
    <li>
    <label for="content">content:</label>
    <textarea class="input" id="content">&nbsp;</textarea>
    </li>             
    <li>
    <xsl:if test="string-length(umbraco.library:RequestForm('submit')) &gt; 0">
     <xsl:value-of select="TestClass:TestFunction('param1', 'param2')"/>
    </xsl:if>
    <input type="submit" class="type-submit" value="submit"/>
    </li>
    </ol>
    </div></form>          
    </div> </div>          
    </xsl:template>

    Thanks,

    kukuwka

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Sep 06, 2010 @ 13:21
    Lee Kelleher
    0

    Hi kukuwka,

    Remove the hash # from the <form> tag... it should still work with it there, but still, its not needed.

    <form action="" method="post">

    Other than that, do as Niels said, add the name="submit" to your button.

    Cheers, Lee.

  • kukuwka 75 posts 96 karma points
    Sep 06, 2010 @ 14:22
    kukuwka
    0

    Thank to everyone.

    It works

  • kukuwka 75 posts 96 karma points
    Sep 06, 2010 @ 15:51
    kukuwka
    0

    Hi,

    I would like to ask how I can get text from input(type="text") in order to pass it to the function (TestFunction).

    Thanks,

    kukuwka

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Sep 06, 2010 @ 15:55
    Matt Brailsford
    0
    <xsl:value-of select="TestClass:TestFunction(umbraco.library:RequestForm('inputFieldName'), 'param2')"/>

    Matt

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Sep 06, 2010 @ 15:57
    Lee Kelleher
    0

    Hi kukuwka,

    First, you'll need to add the "name" attributes to the <input> fields.

    Then you can reference them in the XSLT like so.

    <xsl:value-of select="TestClass:TestFunction(umbraco.library:RequestForm('name'), umbraco.library:RequestForm('content'))"/>

    I still believe that this would be much easier to develop in a .NET user-control.

    Cheers, Lee.

  • praveity 100 posts 125 karma points
    Apr 20, 2011 @ 13:18
    praveity
    0

    Can I do the same xslt-extension call on click event of div?

Please Sign in or register to post replies

Write your reply to:

Draft