Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Using codebehind
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Using codebehind

 Post Reply Post Reply Page  12>
Author
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Topic: Using codebehind
    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.

Back to Top
Diep-Vriezer View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 August 2003
Location: Netherlands
Status: Offline
Points: 831
Post Options Post Options   Thanks (0) Thanks(0)   Quote Diep-Vriezer Quote  Post ReplyReply Direct Link To This Post 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..
Back to Top
Diep-Vriezer View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 August 2003
Location: Netherlands
Status: Offline
Points: 831
Post Options Post Options   Thanks (0) Thanks(0)   Quote Diep-Vriezer Quote  Post ReplyReply Direct Link To This Post 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..
Back to Top
jennysee View Drop Down
Newbie
Newbie


Joined: 09 September 2003
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote jennysee Quote  Post ReplyReply Direct Link To This Post 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' 

 

 

Back to Top
Diep-Vriezer View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 August 2003
Location: Netherlands
Status: Offline
Points: 831
Post Options Post Options   Thanks (0) Thanks(0)   Quote Diep-Vriezer Quote  Post ReplyReply Direct Link To This Post 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
Gone..
Back to Top
jennysee View Drop Down
Newbie
Newbie


Joined: 09 September 2003
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote jennysee Quote  Post ReplyReply Direct Link To This Post 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??
Back to Top
Diep-Vriezer View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 August 2003
Location: Netherlands
Status: Offline
Points: 831
Post Options Post Options   Thanks (0) Thanks(0)   Quote Diep-Vriezer Quote  Post ReplyReply Direct Link To This Post 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..
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.