Output a form within code?

Vote:
 
Can somebody please tell me if the following code snippet is valid using EPiServer 4.61? : http://www.episerver.com/en/EPiServer_Knowledge_Center/FAQ_EPiServer_4/927/929/ Using the sample website, I am trying to access the "Vote" form contained within the "Inspiration" folder. I would then like to output this form within the sidebar of my template, for viewing on the front page and others. (in other words, I'd like a poll showing across multiple pages) The above FAQ appeared to offer a solution, but I cannot get it to work. I created a dynamic property called "RemoteFormProperty" of type "Page", and assigned the "Vote" page (114) to it for my start page. I then created a local variable "StartPageForm" as type EPiServer.WebControls.Property and used the FAQ code: PageData remoteFormPage = GetPage((PageReference)CurrentPage["RemoteFormProperty"]); PropertyForm form = (PropertyXForm)remoteFormPage.Property["Form"]; StartPageForm.InnerProperty = form; ...but I keep getting a "System.NullReferenceException: Object reference not set to an instance of an object." error on the "StartPageForm.InnerProperty = form" line. I have also tried : PropertyXForm form = (PropertyXForm)remoteFormPage.Property["MainXForm"]; ...with the same results. If anybody could suggest where I am going wrong it would be appreciated. /\dam
#13059
Jun 04, 2007 17:19
Vote:
 
Hi Adam! Did you declare the "within" some other databound control in the .aspx/.ascx? If so, the control wont be available until the "outer" control is databound. You'd also have to use FindControl(), or iterate over the child control collection to lookup such a dynamically created control. Regards, Johan Olofsson
#15333
Jun 05, 2007 9:12
Vote:
 
Thanks for your reply! >Did you declare the >"within" some other databound control in the .aspx/.ascx? >If so, the control wont be available until the "outer" control is databound. Not as far as I can tell. >You'd also have to use FindControl(), or iterate over the child control collection >to lookup such a dynamically created control. Does this mean that the FAQ is outdated? If so, would there be any chance of updating it? I'm still unsure of the syntax required to get things working in EPiServer... Many thanks, /\dam
#15334
Jun 06, 2007 10:31
Vote:
 
I am making some progress. My code now reads simply: PageData remoteFormPage = this.GetPage(new PageReference(114)); StartPageForm.InnerProperty = remoteFormPage.Property["MainXForm"]; This correctly outputs the poll from the sample site - I haven't looked at getting the form to submit correctly from any page yet. Ultimately, I need to display the most recent poll created by the admin user, filtered by category based on the current user. I was thinking of doing this via a dedicated folder containing pages, each with a simple poll, and then filtering based on date (most recently created) and category. Any feedback on this idea would be appreciated. /\dam
#15335
Jun 06, 2007 13:24
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.