Copied to clipboard

Flag this post as spam?

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


  • Niemeyer 3 posts 23 karma points
    Apr 01, 2011 @ 10:49
    Niemeyer
    0

    .Net Control with button within a xslt dosen't execute the onClick function

    Hi,

     as the topic says. It's a basic contact form, when the user hits the button it should parse the text within the textboxes and send it via mail or, if some mandatorys textfields are left empty, it should force the user to put text in them.

    Since not all pages of that type should have this kind of form i've added a True/False property and tried to make the control visible by xslt-script. It works all fine, except when you hit the Button nothing happens.

    Is there something i missed, or is it just not possible?

    Greeting R. Niemeyer

    P.S. here is the script:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
    xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">


    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>
    <xsl:variable name="onlineBewerbung" select="string('&lt;?UMBRACO_MACRO macroAlias=&quot;OnlineBewerbung&quot; numberOfItems=&quot;32&quot; eventStartPage=&quot;$currentPage/@id&quot;&gt;&lt;/?UMBRACO_MACRO&gt;')"/>

    <xsl:template match="/">

    <xsl:if test="$currentPage/zeigeOnlinebewerbung = 1">
    <div class="bewerbung_form">
    <h2>Jetzt online bewerben:</h2>
    <xsl:value-of select="umbraco.library:RenderMacroContent($onlineBewerbung, number($currentPage/@id))" disable-output-escaping="yes" />
    </div>
    </xsl:if>

    </xsl:template>

    </xsl:stylesheet>
  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 01, 2011 @ 21:00
    Jan Skovgaard
    0

    Hi Niemyer

    What does the code from the user control look like? It should be possible...but maybe there is some code in the user control that prohibits it somehow?

    /Jan

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Apr 01, 2011 @ 22:02
    Tom Fulton
    1

    Have you wrapped this XSLT macro in a <form runat="server"> tag?  That will be needed for the postback to work.

    ie

    <form runat="server">
    ...
    <umbraco:Macro Alias="YourXsltMacro"></umbraco:Macro>
    ...
    </form>
  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 01, 2011 @ 22:04
    Jan Skovgaard
    0

    Ah yes...of course...the classic runat="server"...how could I forget to mention that one :-)

    /Jan

  • Niemeyer 3 posts 23 karma points
    Apr 01, 2011 @ 22:42
    Niemeyer
    0

    Hi,

     thx for the replies :)

    The Page itself has 4 web user controls, which are doing basicaly the same. The users can fill out text boxes, drop down lists, check boxes, ... and when they click the buttons the page sends a email to me with the stuff they entered, choosen, clicked, whatever. 2 of the controls are called from templates and both work, 2 are called from xslt-scripts and they don't work.

    So i don't think it's the code itself or the missing runat="server" attribute. But the code is on my machine at work which is off for the weekend.

    Tbh i can't imagine nobody ever tried before to get a button click from a control which is loaded by a xslt-script.

    Greets Ralph Niemeyer

  • Richard Soeteman 4045 posts 12898 karma points MVP 2x
    Apr 02, 2011 @ 05:49
    Richard Soeteman
    0

    Hi,

    You can't use server events in Macro's that get called via xslt. This is because of the inner workings of asp.net AKA the Page Lifecycle. I suggest you create a Usercontrol Macro for this situation.

    Cheers,

    Richard

  • Daniel Bardi 927 posts 2562 karma points
    Apr 02, 2011 @ 08:40
    Daniel Bardi
    0

    Only the output of the usercontrol is rendered.. there will be no events to fire.

    An option would be to place the usercontrol in a template and call the render template method from xslt... but at that point you might as well just create a usercontrol macro.

Please Sign in or register to post replies

Write your reply to:

Draft