Print Page | Close Window

Using codebehind

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: ASP.NET Discussion
Forum Description: Discussion and chat on ASP.NET related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=5579
Printed Date: 28 March 2026 at 9:10pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Using codebehind
Posted By: Mart
Subject: Using codebehind
Date Posted: 07 September 2003 at 5:29am

Hello i am new to .Net and thuoght i would try and use codebehind for a page. I made the class in Webmatrix and added

<%@ Codebehind="myclass.vb" %>

This part has worked fine, but i get this error

Server Error in '/' Application.

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30456: 'Button1_Click' is not a member of 'ASP.questionaire_aspx'.

Source Error:

Line 87:                         </p>
Line 88:                         <p align="center">
Line 89:                             <asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="Submit"></asp:Button>
Line 90:                         </p>
Line 91:                     </td>

And the sub button1_click is in my class

What am i doing wrong?

Thanks, Mart.




Replies:
Posted By: Diep-Vriezer
Date Posted: 07 September 2003 at 6:13am
Well, the code-behind file should look like this:

Public Class DisplayStart
Inherits System.Web.UI.Page

Protected WithEvents Button1 As System.Web.UI.WebControls.Button

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init

'CODEGEN: This method call is required by the Web Form Designer

'Do not modify it using the code editor.

InitializeComponent()

End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'Put user code to initialize the page here

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click)

End Class

 

The ASPX header must look like this:

<%@ Page ="vb" AutoWireup="false" Codebehind="DisplayStart.aspx.vb" Inherits="ps.DisplayStart"%>

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="DisplayStart.aspx.vb" Inherits="app.DisplayStart"%>

where app is the name of the application

<%@ Page ="vb" AutoWireup="false" Codebehind="DisplayStart.aspx.vb" Inherits="ps.DisplayStart"%><%@ Page ="vb" AutoWireup="false" Codebehind="DisplayStart.aspx.vb" Inherits="ps.DisplayStart"%><%@ Page ="vb" AutoWireup="false" Codebehind="DisplayStart.aspx.vb" Inherits="ps.DisplayStart"%>

-------------
Gone..


Posted By: Diep-Vriezer
Date Posted: 07 September 2003 at 6:15am
This is just to show you how it works, maybe use a tutorial on creating these pages, since there is alot of useless VS.NET stuff in this one.

-------------
Gone..


Posted By: jennysee
Date Posted: 09 September 2003 at 11:48pm

Hi i try out what u had suggest .

i am using MS visual studio.net and i create the web application name MembershipNew. I had my update.aspx.vb and update.aspx files

 i get this error when i compile  Parser Error Message: Could not load type 'MembershipNew.update' 

 

 



Posted By: Diep-Vriezer
Date Posted: 09 September 2003 at 11:51pm
MorningZ has some usefull links at his site, where they describe howto make a code behind. BTW, Visual Studio .NET always works with code-behind, and there probably is another file, called update.aspx.resx, but just look at his site and you'll see.

http://www.morningz.com/sections/coding/links.aspx - http://www.morningz.com/sections/coding/links.aspx

-------------
Gone..


Posted By: jennysee
Date Posted: 10 September 2003 at 12:12am
i look into the MemmbershipNew folder there is really another file named update.aspx.resx but how relates to the error i mentioned earlier on??


Posted By: Diep-Vriezer
Date Posted: 10 September 2003 at 8:21am

What does your header looks like. You'll have to include:

<%@ ... codebehind="update.aspx.vb" inherrits="AppName.Update"%>

Where AppName is the name of the Application or namespace you declare in the codebehind file.



-------------
Gone..


Posted By: Mart
Date Posted: 10 September 2003 at 9:28am

I have given up with codebehind because its a hassle compiling them an registering them on my webhost, im just stickin to inline

Mart.



Posted By: karp13
Date Posted: 10 September 2003 at 9:37am

Why would you have to register it on you host?

All you have to do is place it in your bin directory at the root of your website or the root of a virtual directory for an application.



Posted By: Diep-Vriezer
Date Posted: 10 September 2003 at 10:46am

I thougth you were using VS.NET

In VS.NET you can easily create and edit code-behind pages. Why don't you use the full capability of ASP.NET? Keep trying.



-------------
Gone..



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net