StrataFrame Forum

trouble converting VB IWebBusinessBindable to C#

http://forum.strataframe.net/Topic18745.aspx

By Govinda Berrio - 8/26/2008

Hi all,



I'm trying to implement the IWebBusinessBindable and IWebListControl with a Telerik RadComboBox. I think I'm on the right track by just copying the code from Strataframe source code, but I'm stuck the conversion of the VB code C#. I ran the code through an online VB-> C# converter and most of it compiles fine except for the "Events" section where the IWebListControl event ListPopulating needs to be implement. The C# code that the converter generates doesn't compile.



Here's the IWebListControl interface snippet

Event ListPopulating(ByVal e As ListPopulatingEventArgs)




Here's how Strataframe implements it in Microfour.Strataframe.UI.Web.DropDownList

Public Event ListPopulating(ByVal e As ListPopulatingEventArgs) Implements IWebListControl.ListPopulating



Friend Sub RaiseListPopulatingEvent(ByVal e As ListPopulatingEventArgs) Implements IWebListControl.RaiseListPopulatingEvent

RaiseEvent ListPopulating(e)

End Sub




Here's the converter generated code, which doesn't compile



public event IWebListControl.ListPopulating;



internal void IWebListControl.RaiseListPopulatingEvent(ListPopulatingEventArgs e)

{

if (ListPopulating != null) {

ListPopulating(e);

}

}




If anyone could shed some light on this, it would be very helpful as I'm not that experienced in .net development.



Thank You,

Govinda
By Greg McGuffey - 8/26/2008

I'm not a C# expert, but I think the problem is in the declaration of the event:



public event IWebListControl.ListPopulating;




which is missing a type. You need to add the delegate type:



public event ListPopulatingEventHandler IWebListControl.ListPopulating;




That probably isn't quite it, but the form needs to be:



public event [delegate type] [event name];




Hope that is helpful! BigGrin
By Govinda Berrio - 8/26/2008

I looks like the solution is that... Thanks Greg.

public event MicroFour.StrataFrame.UI.IWebListControl.ListPopulatingEventHandler ListPopulating;



void IWebListControl.RaiseListPopulatingEvent(ListPopulatingEventArgs e)

{

if (ListPopulating != null) {

ListPopulating(e);

}

}




But now the IWebListControl.PopulateList(params object[] Parameters) interface method won't compile. The error that I'm getting is
Argument '1': cannot convert from 'GKG.WebControls.sfRadComboBox' to 'System.Web.UI.WebControls.ListControl'


void IWebListControl.PopulateList(params object[] Parameters)

{

if (!this.DesignMode)

{

WebListControl.PopulateCombo(this, (MicroFour.StrataFrame.Tools.ITypeResolver)this.Page, Parameters);

}

}




I believe this is because the Telerik RadComboBox doesn't have System.Web.UI.WebControls.ListControl in it's inheritance hierarchy. Can any of the developers look into this because I would really like to use these controls with Strataframe.



Thank You