Hello World Quick Start Tutorial

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
6/6/2014 1:24:49 PM
Gravatar
Total Posts 9

Hello World Quick Start Tutorial

I have been playing with the quick start tutorial such as adding removing controls and seems really straight forward.
But when I tried to add a grid view from the database, it wants a connection string so I can pick the table and fields to display.

When I do this and add it as a feature, the site crashes.
Forgive me as I have little experience with mojoportal, let alone c#, but it seemed straight forward.
I did notice that the connection string I created in the gridview was written to the webconfig file when I added the feature.
I also noticed, it created a webconfig file in the MyCustomModules folder where the ascx pages reside.

My guess is I should be using the current connection string with Mojo and not creating another one.
If that is correct, where do edit the grid view for that connection, or do I need to make some reference to the connection string in the HelloWorld ascx?

I am aware this is inline code, but for my purposes, this is all I need to run simple queries for display or interactivity.

Thanks in advance
Greg
 

6/6/2014 2:20:12 PM
Gravatar
Total Posts 18439

Re: Hello World Quick Start Tutorial

Hi Greg,

When I do this and add it as a feature, the site crashes.

If you're going to try to do developer tasks you're going to have to learn to troubleshoot errors, that is part of the process, you must get the error details and figure out the cause and learn to fix it. 

As far as querying the database and populating a grid, it depends on what tables you want to query and whether those table live in the mojoportal database or not. If you are using the same database then you could use the same connection string.

We actually have a built in tool for interactive queries that can show the query results in a gridview. If you wanted to be able to show those same results elsewhere like on a public page you could use a saved query to populate a grid similar to this article which shows how to use a saved query to populate a chart.  This approach is a reasonable way to implement quick and dirty things though not a way to do professional feature development. If you use a saved query to query tables in the mojoPortal database like in these examples then you don't even have to worry about the connection string since DatabaseHelper already knows the connection string. Your code to bind the grid would look something like this as opposed to the code in the article that populates a chart:

using(IDataReader reader = DatabaseHelper.GetReader(string.Empty, q.Statement))
  {
    grid.DataSource = reader;
    grid.DataBind();
  
  }

If your custom code lives in a Visual Studio web project, you definitely don't want the web.config from that project to be used for anything and you don't want it to overwrite the mojoportal Web.config

Hope that helps,

Joe

6/6/2014 5:35:37 PM
Gravatar
Total Posts 9

Re: Hello World Quick Start Tutorial

Thanks Joe,
Yes, I know this is quick and dirty, but don't tell anyone.
This is on a dev. box on a dev mojoportal so this is mostly for learning experience.
Down the road, I will have a need for a quick and dirty feature at times for small queries or Stored Procedures. These are small tasks of no more than a 100-150 records that never change in size.
Your reply and links are a big help.

 Thanks again

Greg

You must sign in to post in the forums. This thread is closed to new posts.