The file that was revealed is the "code-behind" page (a physical file)
where you can place all of your code.  It has a Page_Load procedure and
any control you draw on the ASP (aspx) page can be referenced from that
"code-behind" page.  For example, if you drag a button onto your ASP
page and double-click on it, you will be taken to the "code-behind" page
and placed at the Click method for that button.  You can then place code
there to be executed when a user clicks on the button.  Very similar to
Visual Basic if you ever did any work with that. You can also directly
influence the properties of your web controls from the "code-behind"
page, like making things visible or invisible, changing textbox/label
values, font colors, etc.  Almost any property of a web control can be
accessed and modified in the "code-behind" page. 

The code-behind page is also a more powerful way of performing
operations that you used to have to do in-line with the old .ASP model.
Things like accessing databases, processing information, creating
objects to store data, etc. can all be done in the "code-behind" page.
For example, you can create a procedure:

Public Sub PopulateUserInfo()
        ' Some code here
End Sub 

that will get your user's personal information from a database, stick it
into a dataset, bind it to a control on your page (like a DataList):


myDataList.Datasource = myDataset
myDataList.DataBind()

and then call that procedure from the "code-behind" page's Page_Load
method:

Private Sub Page_Load()
        PopulateUserInfo()
End Sub

Then, each time the page is loaded it will call the PopulateUserInfo
procedure and display the user's info in your DataList.  Procedures can
also be placed in class files that you add to your project and called
from any page you like, as long as that page can "see" it, so you can
re-use methods/procedures whenever the need arises.

Hope this makes sense/helps!

John

 

-----Original Message-----
From: Ben Joyce [mailto:ben@;babelfish.co.uk] 
Sent: Friday, November 08, 2002 3:59 PM
To: dotnet
Subject: RE: asp.net newbie is curious...


Ahh, yeah... there is a .vb file 'inside' my .aspx file.  I am assuming
this isn't a physical file but a virtual one that contains all the
server-side VB stuff for my script, or something like that anyway.

You mention you haven't done much in-line coding, hmm, may I ask then
how do you build you pages?

Cheers,

 .ben

> -----Original Message-----
> From: Black, John S. [mailto:John.S.Black@;twtelecom.com]
> Sent: 08 November 2002 22:36
> To: dotnet
> Subject: RE: asp.net newbie is curious...
> 
> 
> 
> There is a button at the top of the Project Window that is
> 2nd form the
> right (I think) which will 'Show all Files'.  If you click that you
> should see a + appear next to your WebForm.aspx page.  The 
> Inherits line
> is just the name of the project/solution the file is a part of so that
> shouldn't cause any problems.  Haven't done much in-line coding so am
> not really familiar with the 'Language' property and why it would work
> without it but not work with it.
> 
> Good Luck
> 
> -----Original Message-----
> From: Ben Joyce [mailto:ben@;babelfish.co.uk]
> Sent: Friday, November 08, 2002 3:32 PM
> To: dotnet
> Subject: RE: asp.net newbie is curious...
> 
> 
> Hi John.  Thanks for the quick response.
> 
> I tried changing the case but it just stopped working (without error) 
> again so I've removed the directive.
> 
> I have a suspicion it might be something to do with these bits:
> 
>       Codebehind="WebForm1.aspx.vb"
>       Inherits="WebApplication3.WebForm1"
> 
> I can't see any .aspx.vb files in the project explorer, I'm not really

> sure what all these references are for.  It's all quite overwhelming!
> 
> Cheers,
> 
>  .b
> 
> > -----Original Message-----
> > From: Black, John S. [mailto:John.S.Black@;twtelecom.com]
> > Sent: 08 November 2002 22:20
> > To: dotnet
> > Subject: RE: asp.net newbie is curious...
> > 
> > 
> > 
> > Try using VB instead of vb, I believe it is case sensitive.  Also,
> > pretty sure VB is the default language so I don't think you need to 
> > qualify it with a Page directive.
> > 
> > John
> > 
> > -----Original Message-----
> > From: Ben Joyce [mailto:ben@;babelfish.co.uk]
> > Sent: Friday, November 08, 2002 3:15 PM
> > To: dotnet
> > Subject: asp.net newbie is curious...
> > 
> > 
> > hi all.
> > 
> > well, I have finally sorted out my workstation and have vs.net 
> > installed and working.
> > 
> > I have the Wrox Press book "Professional ASP.NET" (released around 
> > Beta
> > 2) and am just starting to have a go at connecting to
> > datasources, etc.
> > 
> > I'm a bit baffled :)
> > 
> > When I created a new page I got the following at the top:
> > 
> > ----- 8< -----
> > <%@ Page Language="vb" AutoEventWireup="false"
> > Codebehind="WebForm1.aspx.vb" Inherits="WebApplication3.WebForm1"%>
> > ----- >8 -----
> > 
> > I used the same page and wrote some of the example code in, as 
> > follows:
> > 
> > ----- 8< -----
> > <%@Import Namespace="System.Data" %>
> > <%@Import Namespace="System.Data.SqlClient" %>
> > 
> > <html>
> > 
> > <head>
> >     <script language="vb" runat="server">
> > 
> >             sub Page_Load(source as object, e as eventargs)
> >             
> >                     dim myConnection as SQLConnection
> >                     dim myCommand as SQLCommand
> >                     dim myReader as SQLDataReader
> >                     dim SQL as string
> >                     dim ConnStr as string
> >                     
> >                     SQL = "SELECT * FROM Shippers"
> >                     ConnStr =
> "server=capsicum;uid=sa;pwd=;database=Northwind;"
> >                     
> >                     myConnection = New SQLConnection(ConnStr)
> >                     myConnection.Open()
> >                     
> >                     myCommand = New SQLCommand(SQL, myConnection)
> >                     myReader = myCommand.ExecuteReader()
> >                     
> >                     Shippers.DataSource = myReader
> >                     Shippers.Databind()
> >                     
> >                     MyLabel.Text = myConnection.ConnectionString
> >             
> >             end sub
> > 
> >     </script>
> > </head>
> >             
> > <form runat="server">
> > 
> >     <asp:DropDownList id="Shippers" name="Shippers"
> > DataTextField="CompanyName" DataValueField="ShipperID" 
> runat="server"
> > />
> >     <asp:Label id="MyLabel" runat="server" />
> > 
> > </form>
> > </html>
> > ----- >8 -----
> > 
> > What I want to know is why the page wont run with the <%@ Page
> > Language="vb" ... %> code in there, but runs fine if I take it out.
> > 
> > Any ideas?
> > 
> > Also, I am an experienced Classic ASP developer (5+ years) but I'm
> > slightly thrown by the .NET stuff.  Would anyone have any 
> advice for
> > me, things to watch out for, etc, or any good tutorial sites?
> > 
> > Much appreciated.
> > 
> >  .ben
> > 
> > --
> > ben joyce // [EMAIL PROTECTED] // +44 (0)7958 933718 //
> > http://www.babelfish.co.uk
> > 
> > 
> > ---
> > You are currently subscribed to dotnet as: 
> > [EMAIL PROTECTED] To unsubscribe send a blank email to
> > %%email.unsub%%
> > 
> > ---------
> > Administrated by 15 Seconds : http://www.15Seconds.com
> > List Archives/Search : http://local.15Seconds.com/search
> Subscription
> > Information : http://www.15seconds.com/listserv.htm
> > Advertising Information: http://www.internet.com/mediakit/
> > 
> > 
> > 
> > The content contained in this electronic message is not intended to
> > constitute formation of a contract binding TWTC.  TWTC will be 
> > contractually bound only upon execution, by an authorized 
> officer, of
> > a contract including agreed terms and conditions or by express
> > application of its tariffs.
> > 
> > This message is intended only for the use of the individual
> or entity
> > to which it is addressed. If the reader of this message is not the
> > intended recipient, or the employee or agent responsible for 
> > delivering the message to the intended recipient, you are hereby 
> > notified that any dissemination, distribution or copying of this 
> > message is strictly prohibited. If you have received this 
> > communication in error, please notify us immediately by replying to 
> > the sender of this E-Mail or by telephone.
> > 
> > ---
> > You are currently subscribed to dotnet as: [EMAIL PROTECTED] To
> > unsubscribe send a blank email to %%email.unsub%%
> > 
> > ---------
> > Administrated by 15 Seconds : http://www.15Seconds.com
> > List Archives/Search : http://local.15Seconds.com/search
> Subscription
> > Information : http://www.15seconds.com/listserv.htm
> > Advertising Information: http://www.internet.com/mediakit/
> > 
> > 
> 
> 
> ---
> You are currently subscribed to dotnet as:
> [EMAIL PROTECTED] To
> unsubscribe send a blank email to
> %%email.unsub%%
> 
> ---------
> Administrated by 15 Seconds : http://www.15Seconds.com
> List Archives/Search : http://local.15Seconds.com/search Subscription 
> Information : http://www.15seconds.com/listserv.htm
> Advertising Information: http://www.internet.com/mediakit/
> 
> 
> 
> The content contained in this electronic message is not intended to 
> constitute formation of a contract binding TWTC.  TWTC will be 
> contractually bound only upon execution, by an authorized officer, of 
> a contract including agreed terms and conditions or by express 
> application of its tariffs.
> 
> This message is intended only for the use of the individual or entity 
> to which it is addressed. If the reader of this message is not the 
> intended recipient, or the employee or agent responsible for 
> delivering the message to the intended recipient, you are hereby 
> notified that any dissemination, distribution or copying of this 
> message is strictly prohibited. If you have received this 
> communication in error, please notify us immediately by replying to 
> the sender of this E-Mail or by telephone.
> 
> ---
> You are currently subscribed to dotnet as: [EMAIL PROTECTED] To 
> unsubscribe send a blank email to %%email.unsub%%
> 
> ---------
> Administrated by 15 Seconds : http://www.15Seconds.com
> List Archives/Search : http://local.15Seconds.com/search Subscription 
> Information : http://www.15seconds.com/listserv.htm
> Advertising Information: http://www.internet.com/mediakit/
> 
> 


---
You are currently subscribed to dotnet as: [EMAIL PROTECTED] To
unsubscribe send a blank email to
%%email.unsub%%

---------
Administrated by 15 Seconds : http://www.15Seconds.com
List Archives/Search : http://local.15Seconds.com/search Subscription
Information : http://www.15seconds.com/listserv.htm
Advertising Information: http://www.internet.com/mediakit/



The content contained in this electronic message is not intended to
constitute formation of a contract binding TWTC.  TWTC will be
contractually bound only upon execution, by an authorized officer, of
a contract including agreed terms and conditions or by express
application of its tariffs.

This message is intended only for the use of the individual or entity
to which it is addressed. If the reader of this message is not the
intended recipient, or the employee or agent responsible for
delivering the message to the intended recipient, you are hereby
notified that any dissemination, distribution or copying of this
message is strictly prohibited. If you have received this
communication in error, please notify us immediately by replying to
the sender of this E-Mail or by telephone.

---
You are currently subscribed to dotnet as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

---------
Administrated by 15 Seconds : http://www.15Seconds.com
List Archives/Search : http://local.15Seconds.com/search
Subscription Information : http://www.15seconds.com/listserv.htm
Advertising Information: http://www.internet.com/mediakit/


Reply via email to