Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > .NET 1.0 and Visual Studio.NET > VS.NET 2002/2003
|
VS.NET 2002/2003 Discussions about the Visual Studio.NET programming environment, the 2002 (1.0) and 2003 (1.1). ** Please don't post code questions here ** For issues specific to a particular language in .NET, please see the other forum categories.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VS.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 28th, 2004, 11:43 AM
Authorized User
 
Join Date: May 2004
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I mean it seems it is not accessing the aspx.vb
I tried Response.write("test") as well
the code is:

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="Assg2.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
    <HEAD>
        <title>WebForm1</title>
        <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
        <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
        <meta name="vs_defaultClientScript" content="JavaScript">
        <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    </HEAD>
    <body MS_POSITIONING="GridLayout">
        <form id="Form1" method="post" runat="server">
            <asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 328px; POSITION: absolute; TOP: 120px"
                runat="server"></asp:TextBox>
            <asp:Button id="Button1" style="Z-INDEX: 102; LEFT: 320px; POSITION: absolute; TOP: 224px" runat="server"
                Text="Button"></asp:Button>
        </form>
    </body>
</HTML>


for aspx.vb:

Public Class WebForm1
    Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub
    Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
    Protected WithEvents Button1 As System.Web.UI.WebControls.Button

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    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
        Response.Write("something")
        TextBox1.Text = "something"
    End Sub
End Class

 
Old May 28th, 2004, 12:57 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

The page/server never SHOULD access the aspx.vb file. Putting that on the server is pointless. Again, I think you are missing the point. The aspx.vb file contains code that is compiled into an assembly. The fact that the file is named the same as the web page with the additional .vb suffix is completely unrelated to the functioning of ASP.NET. The name (and the attributes regarding "CodeBehind" are for the benefit of visual studio, so it knows how to associate the files in the UI. You could just as easily have a vb faile called abcxyz.vb with a class that inherits from System.Web.UI.Page. Then your ASPX could have Inherits="Assg2.TheClassICreated" and the page would still work.

The point is that all the .vb files are the source for the DLL. They don't need to (and really shouldn't) be on the server. So the problem you are having has nothing to do with the files that are on the server.

I can't see what the problem is in your code. It looks fine to me.
 
Old May 28th, 2004, 02:15 PM
Authorized User
 
Join Date: May 2004
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default

but if i don't put the classThatICreate.vb on the server, how will the button's action be taken? because I see that the button 'onclick' event is stored in the class.vb.
As in the example, will the Response.write("test") work when i click button1 if i don't put the class.vb into the server?

 
Old May 28th, 2004, 02:19 PM
Authorized User
 
Join Date: May 2004
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Should I merge WebForm1.aspx.vb into WebForm1.aspx?

 
Old June 1st, 2004, 01:14 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Do you understand the concept of compiled code? You are obviously running VS.net, and perhaps you are getting confused by what you perceive as running locally and what is really running.

Here are the files that are used for constructing a page:
mypage.aspx - This is the actual page that the browser requests
mypage.aspx.vb - This is a code-behind file that neither the browser or server care about.

How it works (assuming a vb.net web application):
In VS.net, when you "run" the application, VS compiles the application. What this means is that it takes all the files in the web application project that are marked as "Compile" (usually anything ending in .vb) and compiles them ALL into a SINGLE assembly (.DLL file).

mypage.aspx.vb --> mywebapplication.dll

What happens when it actually RUNS:
- Browser requests page "mypage.aspx"
- ASP.net handles the processing of the aspx page and expects to be able to inherit from the class "mypage" (this is what the "inherits" attribute is in the @ Page directive)
- The class "mypage" exists inside of the DLL.
- ASP.net runs the page with the necessary class that it gets from the DLL

What this all means:
The .vb file(s) do not actually have to live with the .aspx file. However, the DLL file that is generated DOES have to live with the .aspx files, inside the application's /bin directory. When you deploy pages to another server, you only need to deploy the page itself (.aspx) and the assembly that contains any required classes (.dll). If you don't have the dll, you will this error:

Parser Error Message: Could not load type 'mywebapplication.mypage'.

If you do NOT get this error, but things still do not work, then there are other problems.
 
Old June 3rd, 2004, 11:06 AM
Authorized User
 
Join Date: May 2004
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ohh.. now it works!

Thanks Peter, your my hero






Similar Threads
Thread Thread Starter Forum Replies Last Post
Uploading Text File to FTP server in vb.net KiruShan .NET Framework 2.0 4 July 29th, 2014 02:02 AM
server error when uploading to remote server ammweb ASP.NET 1.0 and 1.1 Basics 7 July 30th, 2006 01:51 AM
Run CrystalReport.NET app in a remote server hpallavi Crystal Reports 0 February 24th, 2006 05:11 PM
server is not running ASP.NET version 1.1 akthar General .NET 1 August 23rd, 2004 06:23 AM
Uploading files on the remote server shahchi1 VS.NET 2002/2003 2 May 20th, 2004 02:46 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.