Accessing a subBlock methods in code-behind from parent block

Vote:
 

I'd like to access methods from a subBlock, as it was possible before with the CMS 6 without the blocks because we were using UserControls.

Here's some code to explain myself:

 

SubBlock.ascx.cs =>

----------------------------------------------------------------------------------------------

public partial class SubBlock: BlockControlBase<SubBlockBlock>
{

   public string Method1()  { return "A string"; }

}

----------------------------------------------------------------------------------------------

 

ParentBlock.ascx =>

----------------------------------------------------------------------------------------------

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ParentBlock.ascx.cs" Inherits="MyProject.Views.Blocks.ParentBlock" %>

<div>
   <EPiServer:Property ID="SubBlock" runat="server" PropertyName="SubBlock" />
</div>

----------------------------------------------------------------------------------------------

 

ParentBlock.ascx.cs =>

----------------------------------------------------------------------------------------------

public partial class ParentBlock: BlockControlBase<ParentBlockBlock>
{

    public string ParentMethod()  { string aStringToDoSomething = SubBlock.Method1(); } //This of course doesn't work

}

----------------------------------------------------------------------------------------------

 

How can I do something like calling a method on a subBlock, any ideas?

 

#69608
Mar 28, 2013 21:00
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.