Find value of parent textbox control from CMSRepeater item

Sharon Parry asked on August 17, 2018 23:54

My (simplified) scenario is:

Parent page contains a textbox and a cmsrepeater. The cmsrepeater contains a button.

When the button for a displayed entry in the cmsrepeater is clicked, I have to get the value of the textbox located on the parent page.

If I use the standard way of getting - on a user control - the value of a control on its parent, eg 'TextBox txtCheckin = this.Parent.FindControl("txtCheckin") as TextBox', txtCheckin is always null.

Is there a macro that would get the value of the textbox on the parent page?

Recent Answers

Peter Mogilnitski answered on August 20, 2018 22:17

it is probably a question hierarchy. Probably repeater and text box dont have the same parent or master. You need to debug it, i.e. put a break point and see what is this.Parent.ID or name you might just need to go up i.e. this.Parent.Parent.FindControl("txtCheckin") or something

0 votesVote for this answer Mark as a Correct answer

Sharon Parry answered on August 20, 2018 22:38

The repeater and the text box definitely share the Master page, and the text box is definitely on the same page as the repeater.

I ended up resolving it by creating my own custom web part, where I used a standard repeater rather than the CMS Repeater. The problem seems to be trying to go "up the tree" to find something from within a transformation.

0 votesVote for this answer Mark as a Correct answer

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