p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   VS.NET 2002/2003 (http://p2p.wrox.com/forumdisplay.php?f=103)
-   -   Uploading and Running vs.net on remote server (http://p2p.wrox.com/showthread.php?t=13481)

X-Ken May 28th, 2004 11:43 AM

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


planoie May 28th, 2004 12:57 PM

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.

X-Ken May 28th, 2004 02:15 PM

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?


X-Ken May 28th, 2004 02:19 PM

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


planoie June 1st, 2004 01:14 PM

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.

X-Ken June 3rd, 2004 11:06 AM

ohh.. now it works!

Thanks Peter, your my hero



All times are GMT -4. The time now is 12:29 PM.

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