I usually define domain objects in the app_code folder or in separate referenced dll’s when building asp.net web apps (vb, c#). Then, when using one of the data controls (like the GridView data control), I’m able to bind to a “ObjectDataSource” and have
the source of this control be one of the domain objects defined in either the app_code or a referenced dll. The ObjectDataSource doesn’t appear to currently work when used on an IronPython page.
For example, regardless if I create python domain classes in my app_script folder, or other non python referenced external dll’s, the object data source does not recognize any of these classes as valid data sources. If I add another aspx page (of type vb
or c#, not IronPython) to the same web project and then add a Gridview and ObjectDatasource to this non IronPython page, the ObjectDatasource wizard is able to find all the non IronPython classes referenced by the project and they are available as the source
for an ObjectDatasource control.
Will we eventually be able to define IronPython classes in our app_script folder, and then use this as an ObjectDataSource on an IronPython aspx?
The problem is that IronPython classes are not real types in the framework sense. i.e. you can't get a System.Type for them and reflect on the members, which is what ObjectDataSource needs to do.
I think the solution may be to come up with a new type of data source which is more friendly to script objects. We have that on our list of things to investigate.
I sort of expected a problem reflecting upon the Python dynamic script classes, but was surprised that an ObjectDataSource placed on an IP aspx page was not able to reflect
upon externally referenced dll’s (i.e. vb.net and c# dlls’).
I'm sorry, I didn't read your initial mail carefully enough. I also don't understand why it would affect the case where you reference non-Python types. To make sure I understand:
Say you have a C# page with no code and a working ObjectDataSource pointing to classes in App_Code
You then simply change the page's language to IronPython (trivial since there is no code), and and no longer works? What error are you getting?
Either reference an external dll that defines a few business domain classes, and/or create them in app_code folder of the above project. Use either vb or c# to create these classes.
Add a new webform to the project, making sure that its language is set to IronPython.
Switch to design view, and drop an ObjectDataSource onto the page.
Use the ObjectDataSource's smart tag "configure data source", then on the configure data source wizzard, open the drop down list labled "choose your business object". Notice that it's empty.
Delete the ObjectDataSource. Switch back to source view and change the language to "VB" in the aspx.
Save the aspx, close the webform (the form should always be closed and re-opened when switching languages)
Re-open the webform, switch back to the design view, use the smart tag again to "configure data source". This time when you open the "choose your business object" dropdown the list is populated with your reflected class types.
Delete the ObjectDataSource from the page, switch back to source view, and change the language back to IronPython.
Save and close the page.
Re-open the page, switch to design view, and an ObjectDataSource, choose "configure data source", then open the "choose your business object" dropdown. Notice it's empty again.
Thanks Scott, I am now able to repro the issue. Note that this is purely a designer issue, and not a runtime issue. So even though the wizard is broken, if you get the correct ObjectDataSource in your page (e.g. by copying from C# page, ...), it should
run just fine.
scotts
Member
32 Points
17 Posts
ObjectDataSource control and app_script classses
Dec 19, 2006 09:02 PM|LINK
I usually define domain objects in the app_code folder or in separate referenced dll’s when building asp.net web apps (vb, c#). Then, when using one of the data controls (like the GridView data control), I’m able to bind to a “ObjectDataSource” and have the source of this control be one of the domain objects defined in either the app_code or a referenced dll. The ObjectDataSource doesn’t appear to currently work when used on an IronPython page.
For example, regardless if I create python domain classes in my app_script folder, or other non python referenced external dll’s, the object data source does not recognize any of these classes as valid data sources. If I add another aspx page (of type vb or c#, not IronPython) to the same web project and then add a Gridview and ObjectDatasource to this non IronPython page, the ObjectDatasource wizard is able to find all the non IronPython classes referenced by the project and they are available as the source for an ObjectDatasource control.
Will we eventually be able to define IronPython classes in our app_script folder, and then use this as an ObjectDataSource on an IronPython aspx?
davidebb
Contributor
7006 Points
1366 Posts
Microsoft
Re: ObjectDataSource control and app_script classses
Dec 21, 2006 12:35 AM|LINK
Hi Scott,
The problem is that IronPython classes are not real types in the framework sense. i.e. you can't get a System.Type for them and reflect on the members, which is what ObjectDataSource needs to do.
I think the solution may be to come up with a new type of data source which is more friendly to script objects. We have that on our list of things to investigate.
thanks,
David
scotts
Member
32 Points
17 Posts
Re: ObjectDataSource control and app_script classses
Dec 21, 2006 03:10 PM|LINK
Thanks for the feedback David.
I sort of expected a problem reflecting upon the Python dynamic script classes, but was surprised that an ObjectDataSource placed on an IP aspx page was not able to reflect upon externally referenced dll’s (i.e. vb.net and c# dlls’).
Scott
davidebb
Contributor
7006 Points
1366 Posts
Microsoft
Re: ObjectDataSource control and app_script classses
Dec 21, 2006 08:49 PM|LINK
I'm sorry, I didn't read your initial mail carefully enough. I also don't understand why it would affect the case where you reference non-Python types. To make sure I understand:
thanks,
David
scotts
Member
32 Points
17 Posts
Re: ObjectDataSource control and app_script classses
Dec 22, 2006 02:26 PM|LINK
Dave, here are some bullet points:
Thanks,
Scott
davidebb
Contributor
7006 Points
1366 Posts
Microsoft
Re: ObjectDataSource control and app_script classses
Dec 22, 2006 07:12 PM|LINK
Thanks Scott, I am now able to repro the issue. Note that this is purely a designer issue, and not a runtime issue. So even though the wizard is broken, if you get the correct ObjectDataSource in your page (e.g. by copying from C# page, ...), it should run just fine.
I will report the issue to the designer team.
thanks,
David