Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesModule aspx to ascxModule aspx to ascx
Previous
 
Next
New Post
1/28/2011 10:01 AM
 
Hi all

Here's today's dumb newbie question.

Maybe I've missed a tutorial somewhere, but I was under the impression that once I had an aspx working all I had to do was copy and paste the bit between the <form> tags into the ascx and copy the VB code. So, I have a form with a Formview and a whole load of entry items. It all works well, as an aspx. I copied it across to the ascx.

After many hours of narrowing things down, I find that my Dropdownlists (the normal country/region/city thing) don't like me including 'OnSelectedIndexChanged="ddlCountries_SelectedIndexChanged' - a build gives me ''ddlCountries_SelectedIndexChanged' is not a member of 'ASP.Test'. It was a member in the aspx so I'm wondering what I've missed.

Google found a few others who have had the same thing but there was nothing in there that I hadn't already tried. So any advice will be very much appreciated.

TIA

Cheers

Ian
 
New Post
1/28/2011 11:06 AM
 
The error definitely means that it doesn't think "ddlCountries_SelectedIndexChanged" exists as a function in your code behind. Make sure that function is in your code. It would help too if we could see the code, is it small enough to post here? You could email the ascx to me and I'll look at it if you'd like that option too, kedvalson@hotmail.com. Copy and paste makes it easy to miss stuff.
 
New Post
1/28/2011 11:30 AM
 
Kelly Edvalson wrote:
The error definitely means that it doesn't think "ddlCountries_SelectedIndexChanged" exists as a function in your code behind. Make sure that function is in your code. It would help too if we could see the code, is it small enough to post here? You could email the ascx to me and I'll look at it if you'd like that option too, kedvalson@hotmail.com. Copy and paste makes it easy to miss stuff.

  Hi Kelly

Many thanks for your reply. I've trimmed out all the unnecessary stuff. I'm sure you don't need to see 150 lines of SQL. :)

So, View.ascx:

<%@ Control Language="VB" ClassName="Test" CodeBehind="View.ascx.vb" Inherits="DotNetNuke.Entities.Modules.PortalModuleBase" AutoEventWireup="true" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<snip>
<asp:FormView ID="fvTest" runat="server" DataKeyNames="UserName" DataSourceID="sdsTest"
        DefaultMode="Insert" CssClass="formview">
<snip>
<asp:DropDownList ID="ddlCountries" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlCountries_SelectedIndexChanged">
                                        <asp:ListItem Text="--Select Value--" Value="0" />
                                    </asp:DropDownList><br />
<snip>
<asp:formview />


and the View.ascx.vb:

Imports System.IO

Partial Class DesktopModules_Test_View
    Inherits System.Web.UI.UserControl


Protected Sub ddlCountries_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)

<snip>


End Sub

End Class

I hope I've included enough to give you an idea. I know I'm doing something silly, but can't see what it is. I've played around with it quite a bit, so I'm not really sure what I had to start with now.

Many thanks

Cheers

Ian

 
New Post
1/28/2011 11:55 AM
 
The "inherits" tag in your ascx file needs to be the name of the class in your codebehind. It would look something like this
<%@ Control Language="VB" ClassName="Test" CodeBehind="View.ascx.vb" Inherits="MyProjectNamespace.DesktopModules_Test_View" AutoEventWireup="true" %>

Make sure that your code behind file is actually named "View.ascx.vb" also.

One more thing, your partial class is the one that needs to inherit the portalbase. So instead of this:
 "Partial Class DesktopModules_Test_View  Inherits System.Web.UI.UserControl"
you need this "Partial Class DesktopModules_Test_View    Inherits DotNetNuke.Entities.Modules.PortalModuleBase"

 
New Post
1/28/2011 11:55 AM
 
I would recommend getting an example module to compare against to see how it all ties together. I would download this visual studio module template, create a new module and look at how it sets it up, then change your structure to be similar.
http://www.bitethebullet.co.uk/VS2010_DNN_Template.aspx

Seeing a basic module as an example is very helpful if you are new to creating modules.
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesModule aspx to ascxModule aspx to ascx


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out