Trying to make this work with DotNetNuke

Rate It (2)

Last post 01-06-2008 8:33 PM by adefwebserver. 19 replies.

Sort Posts:

  • Trying to make this work with DotNetNuke

    12-31-2007, 3:09 PM
    • Contributor
      5,869 point Contributor
    • adefwebserver
    • Member since 06-07-2003, 8:50 AM
    • Los Angeles, CA
    • Posts 1,186
    • TrustedFriends-MVPs
  • Re: Trying to make this work with DotNetNuke

    12-31-2007, 7:12 PM
    • Contributor
      5,789 point Contributor
    • davidebb
    • Member since 06-11-2002, 12:31 PM
    • Redmond, WA
    • Posts 1,160
    • AspNetTeam

    I'm not too familiar with DotNetNuke, but the error you get may provide some clues:

    "The LinqDataSource 'GridDataSource' doesn't have a TableName attribute, and one could not be inferred from the URL."

    The way Dynamic Data works is that if the data source doesn't explicitly specify the table to use, it tries to infer it from the URL.  It does this based on the pattern specified in web.config, which by default is pattern="~/{table}/{viewName}.aspx".

    What does your URL look like when you get the error?

    David

  • Re: Trying to make this work with DotNetNuke

    12-31-2007, 8:24 PM
    • Contributor
      5,869 point Contributor
    • adefwebserver
    • Member since 06-07-2003, 8:50 AM
    • Los Angeles, CA
    • Posts 1,186
    • TrustedFriends-MVPs

    Thank you for any help you can provide. My URL looks like this:

    http://localhost:49388/DotNetNuke/Home/tabid/36/ctl/ListDetails/mid/371/TableName/Modules/Default.aspx

    However, I think the real issue is if Dynamic Data can be made to work if it can't control the .aspx page?

    With DotNetNuke, it must load the DotNetNuke Default.aspx page. The DotNetNuke Default.aspx page then determines what .ascx controls (these are the DotNetNuke modules) to inject into the page.

    From my notes you can see that I can load the tables that Dynamic Data sees and I can even navigate to a .ascx control that has a DynamicGrid or DynamicListView and get it to display data. I am only able to get it to do this much because I am basically setting all the information for the LinqDataSource control and binding the Dynamic Control (either the Dynamic GridView or DynamicListView) to it.

    It appears that the point I am stopped is that Dyanmic Data will not allow me to tell it what the data source should be so all the other Dynamic Controls (like the FilterRepeater) cannot be set using this method. For example I get errors like:

    System.Exception: The DynamicFilterRepeater 'FilterRepeater' doesn't have a TableName attribute, and one could not be inferred from the URL.  

    This code allowed me to at least stop it from throwing an error when I was navigating AWAY from the page (still throws the error when I navigate to the page):

     

            protected void Page_Init(object sender, EventArgs e)
            {
                this.FilterRepeater.TableName = Request.QueryString["TableName"];
            }
     

    I spent about 6 hours trying to use the URL routing. I was even able to specify a .ascx like this:

     

    <add actions="list,details" viewName="ListDetails" templateFile="../../DesktopModules/DynamicWebsite/ListDetailsTemplate.ascx"/>
            

    and it actually went to the control then threw an error because it wasn't a .aspx page. I then realized that I could not use this "routing" at all (due to the fact that DotNetNuke must control the .aspx page) so I am trying to get Dynamic Data to work by just using it's Dynamic controls. I think I CAN get this to work but Dynamic Data needs to allow me to set the datasource for the controls.

    Right now as far as I can get is to manually set the datasource on the LinqDataSource control and bind the DynamicGridView or DynamicListView to it. Anything else I try to do can't be done because I need a "hook" that will allow me to tell DynamicData what the DataContext or Tablename is.

    Am I totally off here? It seems like it would not defeat the "purpose of Dynamic Data" if you allowed us to tell either the Dynamic Controls or the DynamicData.dll what the DataSource/TableName should be. 

    Now I could create a URL and set a patern but as you see the page must be the DotNetNuke "Default.aspx". In my sample URL above my table Name is "Modules". Could I put a "pattern" in the web.config that would be able to parse the querystring below  and set the DataCountex and Table name correctly?

    http://localhost:49388/DotNetNuke/Home/tabid/36/ctl/ListDetails/mid/371/TableName/Modules/Default.aspx

    What is queryStringKeyPrefix? could that help me here?

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

    I want to eventually create a DotNetNuke module that will allow you to design a table and then it creates the table and the Linq to SQL file and then dynamically allows you to navigate and update and add and delete data from the tables. This could be done by a non-programmer. DotNEtNuke is the "key" because it already has the Admin security/ Ability to export a setup as a module that can then be installed on a production server ect. I can then make Admin screens that allow the end user to create and modify templates.

    But this would have to run "inside" the DotNEtNuke portal and it must control the .aspx page. I think you guys assumed that the .Master page would allow use to still keep the look and feel of the rest of our site, but .ascx controls REALLY give us the full control we need.

    Again, Thank you for any help. I'm just trying to throw real world stuff at you to help you make this the greatest thing since ASP.NET first came out

  • Re: Trying to make this work with DotNetNuke

    12-31-2007, 9:13 PM
    • Contributor
      5,789 point Contributor
    • davidebb
    • Member since 06-11-2002, 12:31 PM
    • Redmond, WA
    • Posts 1,160
    • AspNetTeam

    First, let me say that I am very glad that you are trying to make this work in real world scenarios.  It's likely to be quirky in this initial release, but we will make sure that we end up with the flexibility needed to make this work smoothly.

    So if I understand correctly, you have your own custom URL pattern, and the TableName exists somewhere in there?  I'm a little confused because your refer to a query string, while the sample URL you give doesn't have one.  If 'Modules' is your table name in that URL sample, have you tried setting something like pattern=~/Home/tabid/36/ctl/{viewName}/mid/371/TableName/{table}/Default.aspx?

    Note that in future builds, Dynamic Data will rely on the same routing infrastructure as ASP.NET MVC, instead of its own custom config section.

    David

  • Re: Trying to make this work with DotNetNuke

    01-01-2008, 2:22 AM
    • Contributor
      5,869 point Contributor
    • adefwebserver
    • Member since 06-07-2003, 8:50 AM
    • Los Angeles, CA
    • Posts 1,186
    • TrustedFriends-MVPs

    davidebb:

    So if I understand correctly, you have your own custom URL pattern, and the TableName exists somewhere in there?  I'm a little confused because your refer to a query string, while the sample URL you give doesn't have one.  If 'Modules' is your table name in that URL sample, have you tried setting something like pattern=~/Home/tabid/36/ctl/{viewName}/mid/371/TableName/{table}/Default.aspx?

    DotNetNuke creates "search engine friendly urls" but yes my table name is embeded in that string so that's why I was calling it a Querystring when yeah there no "query part" :)

    You suggestion looks good so I will try it as soon as I can and report back. Thanks!

    Also What is queryStringKeyPrefix?

  • Re: Trying to make this work with DotNetNuke

    01-01-2008, 11:19 AM
    • Contributor
      5,869 point Contributor
    • adefwebserver
    • Member since 06-07-2003, 8:50 AM
    • Los Angeles, CA
    • Posts 1,186
    • TrustedFriends-MVPs

    Darn it didn't work. I suspect the problem is the {view} part. I really don't have a view.

    I posted the latest version of the code I was using at:

    http://www.adefwebserver.com/DotNetNukeHELP/DynamicData/

    I'm sure you guys don't have time to play with DotNetNuke so the easy setup to duplicate my problem is to make a website where you have a page that shows the tables. Then when you click on a table it takes you back to the same page but shows you the table details using the Dynamic GridView. Right now it seems this is not possible.

    It would be possible if I can put in code to tell the Dynamic controls what the datacontext and Table name are. It does not appear that the current or the MVC routing is prepared to handle this.

    Now if you are able to do this then the problem would be that the DotNetNuke Default.aspx page is somehow intercepting this needed information. Perhaps the reason I can't get Dynamic Data to work is that the Dynamic controls are trying to bind to a Data Context that would be there with a normal .aspx page but is not with the DotNetNuke Default.aspx page?

     Thanks!

  • Re: Trying to make this work with DotNetNuke

    01-01-2008, 4:07 PM
    • Contributor
      5,789 point Contributor
    • davidebb
    • Member since 06-11-2002, 12:31 PM
    • Redmond, WA
    • Posts 1,160
    • AspNetTeam

    I think I see why it doesn’t work.  The logic to figure out the table name from the URL is not actually based on the request URL, but on the AppRelativeVirtualPath of the aspx/ascx that has the dynamic controls.  So in your case it’s the path to the ascx, which is not the right thing to look at.  In newer builds using the MVC routing, the table name is figured at at the routing level, so this would I think work better.

    But note that if you don’t care about the linking behavior, you should be able to get most of the Dynamic Data behavior by setting the DataContext/TableName yourself (which it sounds like you tried?).  Basically, in your ListDetailsTemplate, I would add custom logic that sets the TableName on the FilterRepeater and DataSources.  Presumably, you could make a call into your framework that sets up all those things?

    David 

    PS: queryStringKeyPrefix adds an optional prefix to all query string params used by Dynamic Data, and won’t help you much.

  • Re: Trying to make this work with DotNetNuke

    01-01-2008, 4:32 PM
    • Contributor
      5,869 point Contributor
    • adefwebserver
    • Member since 06-07-2003, 8:50 AM
    • Los Angeles, CA
    • Posts 1,186
    • TrustedFriends-MVPs

    davidebb:

    But note that if you don’t care about the linking behavior, you should be able to get most of the Dynamic Data behavior by setting the DataContext/TableName yourself (which it sounds like you tried?). 

    Yes this does work. I am able to get this to show:

    by setting the table name using code like this:

     

    GridDataSource.TableName = Request.QueryString["TableName"];
     

    I could set the links to "drill down" into details manually. If I need to I can "walk through" the tables and foreign keys in the datacontext the same way your code does if I have to.

    davidebb:

    Basically, in your ListDetailsTemplate, I would add custom logic that sets the TableName on the FilterRepeater and DataSources.  Presumably, you could make a call into your framework that sets up all those things?

    And that is where I am currently stuck. The following code won't work :(:

    protected void Page_Init(object sender, EventArgs e)
    {
      this.FilterRepeater.TableName = Request.QueryString["TableName"];
    }

    It doesn't throw an error but it doesn't set the value or it sets it too late. DotNetNuke log shows the following error:

    AssemblyVersion: 04.08.00
    PortalID: 0
    PortalName: My Website
    UserID: -1
    UserName:
    ActiveTabID: 36
    ActiveTabName: Home
    RawURL: /DotNetNuke/Home/tabid/36/ctl/ListDetails/mid/371/TableName/Modules/Default.aspx
    AbsoluteURL: /DotNetNuke/Default.aspx
    AbsoluteURLReferrer:
    http://localhost:49388/DotNetNuke/Home/tabid/36/ctl/ListDetails/mid/371/TableName/Modules/Default.aspx
    UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; .NET CLR 3.5.21022)
    DefaultDataProvider: DotNetNuke.Data.SqlDataProvider, DotNetNuke.SqlDataProvider
    ExceptionGUID: ac2d59b2-5fa8-4106-a568-23d1a0fc1cd1
    InnerException: The DynamicFilterRepeater 'FilterRepeater' doesn't have a TableName attribute, and one could not be inferred from the URL.
    FileName:
    FileLineNumber: 0
    FileColumnNumber: 0
    Method: System.Web.DynamicData.DynamicDataManager.GetTableInternal
    StackTrace:
    Message: System.Exception: The DynamicFilterRepeater 'FilterRepeater' doesn't have a TableName attribute, and one could not be inferred from the URL. at System.Web.DynamicData.DynamicDataManager.GetTableInternal(Control owner, String tableName) at System.Web.DynamicData.DynamicDataManager.GetTable(Control owner, String tableName) at System.Web.DynamicData.DynamicFilterRepeater.<GetColumns>d__0.MoveNext() at System.Web.UI.WebControls.Repeater.CreateControlHierarchy(Boolean useDataSource) at System.Web.UI.WebControls.Repeater.OnDataBinding(EventArgs e) at System.Web.UI.WebControls.Repeater.DataBind() at System.Web.DynamicData.DynamicFilterRepeater.OnInit(EventArgs e) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.AddedControl(Control control, Int32 index) at System.Web.UI.ControlCollection.Add(Control child) at DotNetNuke.UI.Skins.Skin.InjectModule(Control objPane, ModuleInfo objModule, PortalSettings PortalSettings)

    If you can get me past this point then I think I can get this thing working :)

  • Re: Trying to make this work with DotNetNuke

    01-01-2008, 5:14 PM
    • Contributor
      5,789 point Contributor
    • davidebb
    • Member since 06-11-2002, 12:31 PM
    • Redmond, WA
    • Posts 1,160
    • AspNetTeam

    You get this error because your Page_Init gets called after all the control's Init, so the FilterRepeater fails before you get to change the TableName (presumably, your code is never called at all).

    I think you could work around by adding a helper control on the page, before the FilterRepeater.  Make your control do something like this:

     

        public class TestControl : Control {
            protected override void OnInit(EventArgs e) {
                base.OnInit(e);
    
                string tableName = Request.QueryString["TableName"];
    
                var filterRepeater = (DynamicFilterRepeater)FindControl("FilterRepeater");
                filterRepeater.TableName = tableName;
    
                var gridDS = (LinqDataSource)FindControl("GridDataSource");
                gridDS.TableName = tableName;
    
                var detailsDS = (LinqDataSource)FindControl("DetailsDataSource");
                detailsDS.TableName = tableName;
            }
        }
    
      

    Sure, it's a hack, but at this point let's try to get you going any way we can.  We'll clean up later! :)

  • Re: Trying to make this work with DotNetNuke

    01-01-2008, 7:00 PM
    • Contributor
      5,869 point Contributor
    • adefwebserver
    • Member since 06-07-2003, 8:50 AM
    • Los Angeles, CA
    • Posts 1,186
    • TrustedFriends-MVPs

    Darn we are so close! I don't know why I can't make it work. It didn't work with DotNetNuke so I created a non DotNetNuke example (see below). It didn't work there either. It appears the "OnInit" is not being called.

    To reproduce my error. Hopefully it's just something I'm doing wrong: 

    1) Create a normal Dynamic Data Site using the Dynamic Data Template.

    2) Insert and replace the files from this .zip file :

    DynamicDataControlTest.zip

    3) The first page will work:

    4) The second page will throw an error:

  • Re: Trying to make this work with DotNetNuke

    01-01-2008, 9:19 PM
    Answer
    • Contributor
      5,789 point Contributor
    • davidebb
    • Member since 06-11-2002, 12:31 PM
    • Redmond, WA
    • Posts 1,160
    • AspNetTeam

    I meant something slightly different, using a helper custom control instead of doing the logic directly in the ascx's OnInit.  Try this revised version.

    David

  • Re: Trying to make this work with DotNetNuke

    01-02-2008, 12:19 AM
    • Contributor
      5,869 point Contributor
    • adefwebserver
    • Member since 06-07-2003, 8:50 AM
    • Los Angeles, CA
    • Posts 1,186
    • TrustedFriends-MVPs

    I'm speechless.

    I hate that I have to go to bed tonight and can't try this on the DotNetNuke module until tomorrow. And I know I can get the "drill down" working also. I'll get this module finished and put it out there as an example of what Dynamic Data can do then I'll fix it when you drop the next CTP because I expect everything will break :)

    I can't thank you enough!

  • Re: Trying to make this work with DotNetNuke

    01-02-2008, 9:25 AM
    • Contributor
      5,869 point Contributor
    • adefwebserver
    • Member since 06-07-2003, 8:50 AM
    • Los Angeles, CA
    • Posts 1,186
    • TrustedFriends-MVPs

    Yes this works with DotNetNuke also.

    It appears I will be able to use a lot of the built in functionality to allow for the "drill down" through the table relationships. The GridView shows the links they just go to the wrong place. I want to duplicate all the functionality of the normal Dynamic Data Template

    I hope to have something working the next 3-4 weeks. It will be Open Source so others will be able to use it as example of using Dynamic Data in their own projects.

    The ability to use Dynamic Data in this manner allows the developer full control. You should be very happy with the direction of your project.

  • Re: Trying to make this work with DotNetNuke

    01-02-2008, 2:03 PM
    • Contributor
      5,789 point Contributor
    • davidebb
    • Member since 06-11-2002, 12:31 PM
    • Redmond, WA
    • Posts 1,160
    • AspNetTeam

    This is great!  I think you may be able to get the links going to the right place by tweaking the ForeignKey.ascx and Children.ascx field templates.

    And yes, you're right that the next build will likely break what you have, but it should be easily fixable (and hopefully it'll be less hacky!).

    Let me know when you have something ready, and I'll blog about it.

    thanks,
    David

  • Re: Trying to make this work with DotNetNuke

    01-03-2008, 12:44 PM
    • Contributor
      5,869 point Contributor
    • adefwebserver
    • Member since 06-07-2003, 8:50 AM
    • Los Angeles, CA
    • Posts 1,186
    • TrustedFriends-MVPs

    I am going to make this work first as a normal ASP.NET application (non DotNetNuke module). I have posted the "starting point" here:

    http://www.adefwebserver.com/DotNetNukeHELP/DynamicData/Non_DNN_DynamicDatTest.htm

    You should be able to just unzip it, open it with Visual Studio click the F5 key to run it.

    Anyone interested in working on this with me over the next 3-4 weeks feel free to contact me at the email listed on that page.

    After we take it as far as we can I'll make a DNN Module so both exampes will be avalaible

Page 1 of 2 (20 items) 1 2 Next >