Hmmm really ...
- I find it hard to believe that none of the books on ASP.NET 2.0 explain the standard method for how to handle a button click event - or any other event in ASP.NET for that matter.
But hey regardless >>>
1. your module has a mymodule.aspx file that declares the layout of the module - something like ...<asp:TextBox ID="txtSomeData" runat="server" Width="500px"></asp:TextBox>
<asp:Button ID="cmdSaveChanges" runat="server" Text="Save Data" />
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="MyModule.ascx.vb" Inherits="MyMod.Modules.MyModules.MyModule" %>
2. The first line declares a code behind file 'CodeFile' - which is stored in the same folder as the aspx file:
This is where you put your CODE: mymodule.aspx.vb
It will look something like the following
Some imports and stuff here:
Namespace
Partial Class MyModule
Inherits DotNetNuke.Entities.Modules.PortalModuleBase
Protected Sub cmdSaveChanges_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSaveChanges.Click
' The Handles statement at the end of the Subroutine declaration attaches this function to the CLICK action of the cmdSaveChanges button' Your code to save the data goes here
' Something like the following assuming you have set up DAL or DAL+
Dim myCTL as NEW MyModule.MyModuleController
Dim myINFO as NEW MyModule.MyModuleInfo
myINFO.SomeText = txtSomeData.Text
myCTL.add( myINFO)
End Sub
End Class
End Namespace
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Now you should note that - BOTH these file are stored in the \DesktopModules\MyModule folder
The code is NOT stored in the App_Code directory ...
The only sort of code that should be put in the App_Code directory are generic class definitions such as the Controller and Info classes for your Data Access layer.
For example: in the file above the two classes instantiated here - would be defined in .vb class files in the App_Code directore
Dim myCTL as NEW MyModule.MyModuleController
Dim myINFO as NEW MyModule.MyModuleInfo
>>>>>>
Hope this helps to make things clearer for you
Westa
MyMod.Modules.MyModules