Fire Click Event on Repeater Transformation

Sharon Parry asked on November 12, 2017 22:57


This is a Version 9.0.37 project.

How can I get a button (or link) click event to fire in a repeater transformation?

Scenario is document types are listed on a page displaying brief details via the relevant "Preview" transformation. I need to add a click-event to the transformation which will trigger server-side functionality. The functionality is actually to trigger an email, but that's not important. The issue is I can't get any button or link to fire.

Following the way it appears the ShoppingCartItemSelector.ascx is created and added to the default cms.product.preview transformation - which includes the btnAdd_Click event to add an item to the shopping cart - what I've done is:

  1. Created a CMSUserControl, with 2 string properties that are passed as variables to the click event
  2. On the ascx page, added a CMSButton as <cms:CMSButton ID="btnSubmit" runat="server" ButtonStyle="Primary" CssClass="FormButton" Text="Send" />
  3. Added btnSubmit.Click += btnSubmit_Click; to the OnInit(EventArgs e)
  4. Added my private void btnSubmit_Click(object sender, EventArgs e)
  5. On the preview transformation, I've added the user control as <uc1:emailpropertyowner runat="server" ID="emailpropertyowner" BusinessName='<%# Eval("BusinessName") %>' SendTo='<%# Eval("Email") %>' />
  6. The data is displayed on the page with the Repeater web part, specifying the Preview transformation

When the listing page is loaded, the two properties (BusinessName and Email) are being loaded correctly for each individual item. But I can't get the btnSubmit_Click to fire.

btw - no problem at all getting a button to fire the click event on the selected item transformation for the same document type.

Recent Answers

Trevor Fayas answered on November 13, 2017 14:03

How the web forms works is first it builds the controller, then leads any value from the post back into the values, then triggers any triggers (such as the button click). It lately determines what was clicked based on position and ids

If your button was on the normal transformation, the selected item transformation is technically a "different button" so it won't triggers, it was looking for the button in the normal transformers spot.

See if you can't remove the selected item transformation and see if it works, you may just need to alert slightly the normal transformation so it works for both selected and non and not have a selected transformation all together.

See if that works!

0 votesVote for this answer Mark as a Correct answer

Sharon Parry answered on November 13, 2017 19:54

Hi Trevor,

Removing the Selected Item Transformation altogether makes no difference. HOWEVER ... I've stumbled upon the problem!

-- the Required Field validators!!! --

I had field validators to check required as well as valid email entry. The whole (small) form is displayed in a collapsible panel. Testing on a page with only 3 or 4 items listed, I opened all the panels, and could then easily see that submitting from only one of the forms triggered the validators for all of the forms! Just as an experiment, I entered data into all of the forms, and then submitted only one of them. Whalla! The form where I had clicked the submit button was the one that was actually submitted.

Will scrap the field validators and go for either some javascript, or just do the checking in the Submit code.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.