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).
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
Hi Kukuwka,
You could check for a Form variable to see if the page is a postback?
Matt
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
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.
Makse sure your form method is post.
AND Make that:
<input type="submit" NAME="submit" value="submit"/>
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"> </textarea>
</li>
<li>
<xsl:if test="string-length(umbraco.library:RequestForm('submit')) > 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
Hi kukuwka,
Remove the hash # from the <form> tag... it should still work with it there, but still, its not needed.
Other than that, do as Niels said, add the name="submit" to your button.
Cheers, Lee.
Thank to everyone.
It works
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
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.
I still believe that this would be much easier to develop in a .NET user-control.
Cheers, Lee.
Can I do the same xslt-extension call on click event of div?
is working on a reply...