Simple Feature with Code Behind

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.
7/21/2011 10:33:24 AM
Gravatar
Total Posts 199

Simple Feature with Code Behind

I watched the video on the guest book and also read the "Hello World Quick Start".  Now that I have the basic understanding I attempted to convert the "Hello World Quick Start" to a code behind project to see if I could get it working.

I got everything built as a separate project and it does build fine without errors.

I take the dll and place it in the bin folder and then I place the .ascx in my newly named folder under the root.

It installs and is available in the feature drop menu.

when I place it on a page it does not show up and I do not get an error??

Does anyone have any ideas?

7/21/2011 10:37:54 AM
Gravatar
Total Posts 1203
Proud member of the mojoPortal team

Help support mojoPortal!
Add-on modules

Re: Simple Feature with Code Behind

Every time I've had this problem it was due to mismatched tags in my .ascx file. There should be an error in Administration, System Log with more specifics.

7/21/2011 11:08:18 AM
Gravatar
Total Posts 199

Re: Simple Feature with Code Behind

Nice log - I am now trying to work through this error I found:

\Web\FormPreMade\FormDigital.ascx(14): error CS1061: 'ASP.formpremade_formdigital_ascx' does not contain a definition for 'chkAutoPostBackTest_CheckedChanged' and no extension method 'chkAutoPostBackTest_CheckedChanged' accepting a first argument of type 'ASP.formpremade_formdigital_ascx' could be found (are you missing a using directive or an assembly reference?)

7/21/2011 12:22:25 PM
Gravatar
Total Posts 199

Re: Simple Feature with Code Behind

well I am at a loss, I have the following references in the code behind and still no good.  I got this running with inline code in 10 minutes with no trouble.  Any direction would be appreciated?

namespace digital.Web.UI.FormPreMade
{
    public partial class FormDigital : System.Web.UI.UserControl
    {

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Globalization;
using mojoPortal.Business;
using mojoPortal.Business.WebHelpers;
using mojoPortal.Web.Framework;
using mojoPortal.Web;
using mojoPortal.Web.Controls;
using mojoPortal.Web.UI;
using mojoPortal.Web.Editor;
using mojoPortal.Net;

7/21/2011 12:24:19 PM
Gravatar
Total Posts 18439

Re: Simple Feature with Code Behind

the error is about your event wiring

you need to either use AutoEventWireup="true" in the .ascx file or else you need to wire up the events from code in the OnInit event in code behind.

Hope that helps,

Joe

7/21/2011 12:47:41 PM
Gravatar
Total Posts 199

Re: Simple Feature with Code Behind

Ok - thank you so far and I think I have it, but still not 100% working:  here is what I did so far:A

ascx now has - AutoEventWireup="True"
------------------------

when I copied the code from inline it had this:

void chkAutoPostBackTest_CheckedChanged

void ddColors_SelectedIndexChanged

I changed it to this once I noticed it and then it correctly displayed when I did:

protected void chkAutoPostBackTest_CheckedChanged(object sender, EventArgs e)

protected void ddColors_SelectedIndexChanged(object sender, EventArgs e)
-------------------------------

Now I am getting this error when trying to post back: 

The HTTP verb POST used to access path '/' is not allowed.
   at System.Web.DefaultHttpHandler.BeginProcessRequest(HttpContext context, AsyncCallback callback, Object state)

7/21/2011 1:01:14 PM
Gravatar
Total Posts 18439

Re: Simple Feature with Code Behind

Since you enabled AutoEventWireup be sure to comment out the code in OnInit that is wiring up the page load event because that would make it fire the event twice.

Regarding the postback error at /, that is a known issue with the VS Web Server, it doesn't happen in IIS, so if you can use IIS or probably IIS Express instead of VS web server that will solve it for you.

Or move your custom feature to a different page than home page for development purposes and just know that this is a known issue and it doesn't happen in production. It also doesn't happen if using an url like /home.aspx, it only happens when the url is / 

Hope that helps,

Joe

7/21/2011 1:18:55 PM
Gravatar
Total Posts 199

Re: Simple Feature with Code Behind

EXCELLENT! - I now have it working.  I have to say that it is this kind of help that keeps me with your product and in my opinion makes if superior to all others.

This is all part of learning for me and I will be making some custom features to experiment with. 

Thanks as always!

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