Global subroutines

F

fd123456

Hi Tom !

Sorry about the messy quoting, Google is playing tricks on me at the
moment.
Global.asax is where you normally have the Global Application
and Session variables and code to manipulate them. It starts
and ends with <script></script> tags.

Yours looks like a compiled version of it.

It is just like any ASP.net page. If you use code-inside, you
surround the code with the script tags. To make the code into
a code-behind file, you move the code to a new file and leave
out the script tags.

I had never thought of it that way. I'm not saying you're wrong, to be
honest I'm not at all sure, but :
1) I've searched hi and lo and can't find anything resembling script
tags in Global.asax.
2) There has to be a Global shared (static) class, because that's
where the variables are held.
3) In VS, contrarily to plain aspx pages, you don't have access to
HTML code for Global.asax (usually, an aspx combo has three different
views : the html view and the design view, which are two tabs on the
same window, and the code-behind file which sits in another window.
There's no design or html tab in Global.asax.
4) As far as I know, aspx stands for Active Server Page eXtended(?),
asax stands for Active Server Application eXtended(?). It's supposed
to be an app, not an page as such. You cannot, for instance, drop a
html table on Global.asax, but mind you, you can drop Windows Forms
controls on it !!

So, I do believe it's not an aspx but a proper app, contained in a
class, and not enclosed in a script block. Again, I could be wrong. I
wish some guru would help us there.
To have a class, I think you would need to compile the file, as you said
and you would have to have the codebehind/inherits on all my pages. I am
trying to get around this.

You definitely need to compile the file in any case. Compiling it
creates a dll in a bin directory, without which no aspx page can be
served (plain html can, though, but that's IIS working under the
scene). You don't have to inherit it on any page, because the
structure is as follows :

Global.asax inherits from the System.Web.HttpApplication class and is
inside the namespace that's named after your project. As it is shared,
it can be used from any other object that is inside that namespace, so
any page inside that namespace can refer to Global.asax simply by
using, for instance, "Global.SomeMethod" (provided that method is
public, obviously).
Pages inherit from System.Web.Ui class. They don't need to inherit
from the application itself (read : they musn't).
Each page has an associated code-behind file, and the aspx file
inherits from the class that lies in the code-behind file. With VS,
all this is totally transparent and taken care for you by the
Framework.
The other problem is - how would I handle 2 codebehind files. Each
aspx page would have it's own code behind and then you have the
Global one. How would you set that up in your ASP pages (you would
need 2 inherits and 2 codebehind statements).

You don't. Again, I think your misconception comes from the fact that
you think the app is not compiled. Think of it this way : the app
contains many classes, some being pages, some being code-behind files,
and one being the Global object. All these classes can (theoretically)
talk to each other, and that's why, to return to the beginning of your
question, you can include shared methods in the Global class and use
them from other classes (code-behind files).
I did that last night, as you suggested, and just have to wait for the CD.

Well, that's very good news for you, because I'm positive that it'll
all become clear very quickly, and I'm also quite sure that you'll
have tremendous fun. VS is the best toy I ever dreamed of, it's fast,
deep, smart, coherent and has the most impressive optimisations. In a
month and a half, I've developped a program that used to cost around
100.000 $ five years ago. I'm in no way affiliated blah blah,
obviously.

So, have fun with it !

Michel
 
T

tshad

fd123456 said:
Hi Tom !

Sorry about the messy quoting, Google is playing tricks on me at the
moment.


I had never thought of it that way. I'm not saying you're wrong, to be
honest I'm not at all sure, but :
1) I've searched hi and lo and can't find anything resembling script
tags in Global.asax.
2) There has to be a Global shared (static) class, because that's
where the variables are held.
3) In VS, contrarily to plain aspx pages, you don't have access to
HTML code for Global.asax (usually, an aspx combo has three different
views : the html view and the design view, which are two tabs on the
same window, and the code-behind file which sits in another window.
There's no design or html tab in Global.asax.
4) As far as I know, aspx stands for Active Server Page eXtended(?),
asax stands for Active Server Application eXtended(?). It's supposed
to be an app, not an page as such. You cannot, for instance, drop a
html table on Global.asax, but mind you, you can drop Windows Forms
controls on it !!

So, I do believe it's not an aspx but a proper app, contained in a
class, and not enclosed in a script block. Again, I could be wrong. I
wish some guru would help us there.

You may be correct.

I know the Global.asax has script tags (only because that was the way the
example program I used a while ago had it set up). In the books I have,
such as "ASP.net: Tips, Tutorials and Code" - it shows it with the script
tags.

Maybe it doesn't matter. Maybe .net just throws it away. I assume that if
you don't have script tags in yours and I do in mine, it isn't an issue with
..net.
You definitely need to compile the file in any case. Compiling it
creates a dll in a bin directory, without which no aspx page can be
served (plain html can, though, but that's IIS working under the
scene). You don't have to inherit it on any page, because the
structure is as follows :

Global.asax inherits from the System.Web.HttpApplication class and is
inside the namespace that's named after your project. As it is shared,
it can be used from any other object that is inside that namespace, so
any page inside that namespace can refer to Global.asax simply by
using, for instance, "Global.SomeMethod" (provided that method is
public, obviously).
Pages inherit from System.Web.Ui class. They don't need to inherit
from the application itself (read : they musn't).
Each page has an associated code-behind file, and the aspx file
inherits from the class that lies in the code-behind file. With VS,
all this is totally transparent and taken care for you by the
Framework.

So if I compile it, would I end up with Global.dll?

With a regular code behind, I would compile it like so:

vbc /t:library something.vb

This would give me something.dll.

Would I compile the Global.asax something like:

vbc /t:library Global.asax

To get get Global.dll

Or would I need to name it Global.asax.vb and do:

vbc /t:library Global.dll
You don't. Again, I think your misconception comes from the fact that
you think the app is not compiled. Think of it this way : the app
contains many classes, some being pages, some being code-behind files,
and one being the Global object. All these classes can (theoretically)
talk to each other, and that's why, to return to the beginning of your
question, you can include shared methods in the Global class and use
them from other classes (code-behind files).


Well, that's very good news for you, because I'm positive that it'll
all become clear very quickly, and I'm also quite sure that you'll
have tremendous fun. VS is the best toy I ever dreamed of, it's fast,
deep, smart, coherent and has the most impressive optimisations. In a
month and a half, I've developped a program that used to cost around
100.000 $ five years ago. I'm in no way affiliated blah blah,
obviously.

Should be here soon.

Thanks,

Tom
 
F

fd123456

Hi Tom !
I know the Global.asax has script tags (only because that was the way the
example program I used a while ago had it set up). In the books I have,
such as "ASP.net: Tips, Tutorials and Code" - it shows it with the script
tags.

Maybe it doesn't matter. Maybe .net just throws it away. I assume that if
you don't have script tags in yours and I do in mine, it isn't an issue with
.net.

OK, I think I understand now. I opened the Global.asax file with
Notepad, and I have this (and only this):

<%@ Application Codebehind="Global.asax.cs"
Inherits="myNamespace.Global" %>

When I open an aspx page, I get this:

<%@ Page language="c#" Codebehind="myPage.aspx.cs"
AutoEventWireup="false" Inherits="myNamespace.myPage" %>

So, it is indeed a place where you *can* put script tags. But the
architecture of Visual Studio makes it so you don't. Note the
directives : Global is an "Application" and pages are "Page"; and the
App has no language specified.
So if I compile it, would I end up with Global.dll?
With a regular code behind, I would compile it like so:
vbc /t:library something.vb
This would give me something.dll.

Would I compile the Global.asax something like:
vbc /t:library Global.asax
To get get Global.dll
Or would I need to name it Global.asax.vb and do:
vbc /t:library Global.dll

Ouch. The problem is, I have never tried to compile anything out of
VS, because it does it automatically (fairly complex site with 30+
auto-configuring pages, 10 databases: 1 keystroke, 2 seconds). But it
doesn't compile as Global.dll, the whole thing is compiled into one
"myNamespace.dll": all page code-behinds, all classes, Global, all
User Control code-behinds, the works.

So I wouldn't know about the switches. Definitely, this has to do with
Namespaces. It should be compiled as a library, that's for sure, but I
don't know how you go about it. My first guess would be something
like:

vbc /t:library Global.asax.vb myFirstPage.vb mySecondPage.vb
out:myNamespace.dll

If I were you, I'd try this : create one Global.asax containing the
line mentioned above. Create one Global.asax.vb containing :

Imports System.Web
Imports System.Web.SessionState

Public Class Global
Inherits System.Web.HttpApplication

Public Sub New()
MyBase.New()
InitializeComponent()
End Sub

Private components As System.ComponentModel.IContainer

<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
components = New System.ComponentModel.Container()
End Sub

Public Test() as String
Return "hello";
End Sub
End Class

Create one "TestPage.aspx" containing :

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="TestPage.aspx.vb" Inherits="myNamespace.TestPage"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>test</title>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<asp:Label id="Label1" runat="server"></asp:Label>
</form>
</body>
</HTML>

And finally, one TestPage.vb containing:

Public Class TestPage
Inherits System.Web.UI.Page
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Label1.Text = Global.Test
End Sub
End Class

(watch the line feeds)

Then, compile it (unfortunately, I can't help you there) and try
http://localhost/myNamespace/TestPage.aspx.

You might need a Web.config file. If it's the case and you can't wait
for your VS to arrive, just say so and I'll give you a generic one.
But with all this, you should have a proper web app (provided you have
declared your app as a folder in IIS) and a working test page calling
a global routine in the Global class (phew!).

If you manage all this without VS, then I'm in awe.

Another thought : maybe it could help you if I sent you a "blank"
project, containing everything, the project files, the test page and
the global files? If so, just give me your mail adress (don't forget
to put nospam bs in it) and I'll send it to you.

Best of luck !

Michel
 
T

tshad

fd123456 said:
Hi Tom !


OK, I think I understand now. I opened the Global.asax file with
Notepad, and I have this (and only this):

<%@ Application Codebehind="Global.asax.cs"
Inherits="myNamespace.Global" %>

When I open an aspx page, I get this:

<%@ Page language="c#" Codebehind="myPage.aspx.cs"
AutoEventWireup="false" Inherits="myNamespace.myPage" %>

So, it is indeed a place where you *can* put script tags. But the
architecture of Visual Studio makes it so you don't. Note the
directives : Global is an "Application" and pages are "Page"; and the
App has no language specified.


Ouch. The problem is, I have never tried to compile anything out of
VS, because it does it automatically (fairly complex site with 30+
auto-configuring pages, 10 databases: 1 keystroke, 2 seconds). But it
doesn't compile as Global.dll, the whole thing is compiled into one
"myNamespace.dll": all page code-behinds, all classes, Global, all
User Control code-behinds, the works.

So I wouldn't know about the switches. Definitely, this has to do with
Namespaces. It should be compiled as a library, that's for sure, but I
don't know how you go about it. My first guess would be something
like:

vbc /t:library Global.asax.vb myFirstPage.vb mySecondPage.vb
out:myNamespace.dll

If I were you, I'd try this : create one Global.asax containing the
line mentioned above. Create one Global.asax.vb containing :

Imports System.Web
Imports System.Web.SessionState

Public Class Global
Inherits System.Web.HttpApplication

Public Sub New()
MyBase.New()
InitializeComponent()
End Sub

Private components As System.ComponentModel.IContainer

<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
components = New System.ComponentModel.Container()
End Sub

Public Test() as String
Return "hello";
End Sub
End Class

Create one "TestPage.aspx" containing :

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="TestPage.aspx.vb" Inherits="myNamespace.TestPage"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>test</title>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<asp:Label id="Label1" runat="server"></asp:Label>
</form>
</body>
</HTML>

And finally, one TestPage.vb containing:

Public Class TestPage
Inherits System.Web.UI.Page
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Label1.Text = Global.Test
End Sub
End Class

(watch the line feeds)

Then, compile it (unfortunately, I can't help you there) and try
http://localhost/myNamespace/TestPage.aspx.

You might need a Web.config file. If it's the case and you can't wait
for your VS to arrive, just say so and I'll give you a generic one.
But with all this, you should have a proper web app (provided you have
declared your app as a folder in IIS) and a working test page calling
a global routine in the Global class (phew!).

If you manage all this without VS, then I'm in awe.

Another thought : maybe it could help you if I sent you a "blank"
project, containing everything, the project files, the test page and
the global files? If so, just give me your mail adress (don't forget
to put nospam bs in it) and I'll send it to you.

I just got the VS today and will probably not get to it until next week, but
I will try your examples. I need to get a handle on the whole code behind
business.

I just use Dreamweaver and built a couple sites with about 40 or so pages
(that would double of course with code behind).

I'll let you know how I come out.

Thanks,

Tom
 
F

fd123456

tshad said:
I just got the VS today and will probably not get to it until next week, but
I will try your examples. I need to get a handle on the whole code behind
business.

Lucky you ! :)
I just use Dreamweaver and built a couple sites with about 40 or so pages
(that would double of course with code behind).

Actually, it wouldn't, because, all things being equal, the
code-behind belongs to the page itself, so it would still be 40 pages,
each one being comprised of code-afore html and code-behind VB (so to
speak).

I'm sure you'll keep us all posted, because your questions will begin
to flow from next week on :D Have fun!

Michel
 
T

tshad

fd123456 said:
Lucky you ! :)
I finally loaded my trial version of VS and need a little help getting
started with setting up the Global.asax.vb file to do my shared functions.

I am not starting a problem (I already have that set up without Code-behind
at the moment).

I just want to create the Global.asax.vb file. I am not sure what I write
and what VS does for me.

Do I just start with a new Text file?

How do I tell it that this is the Global.asax file (other than saving it
that way)?

Where do I tell it to compile it?

I assume this will create my .dll that I move to my bin folder.

Thanks,

Tom
 
F

fd123456

Hi Tom!

Here is a somewhat standard procedure to achieve what you're looking
for.

As you will see, the "Visual" in "Visual Studio" will save you a lot
of time/hassles.

I will assume that you have never used any version of VS.

1) Launch VS. Create a Solution (File / New / New Solution). In the
Dialog that appears, just type a name, don't choose "Visual Basic
Projects" just yet. Let's call it TomSolution. Click OK.

2) Show the Solution Explorer window by choosing that option in the
View menu (I guess it's called View, my version isn't an english one,
third menu anyway).

3) Right-click on the Solution name in the Solution Explorer window,
and click "Add / Add new project".

4) In the dialog that appears, you can now choose "Visual Basic
Projects". Then choose "ASP.Net Web Application" in the icon list on
the right. Give it a name - TomApp - and click OK. In fact, you're not
giving a name, but the full path of the web app, in this case,
"http://localhost/TomApp".

5) After a few seconds, a default project is created. The Solution
Explorer shows a list of new items :
TomApp (the project)
References (a folder)
AssemblyInfo.vb
Global.asax
Styles.css
Web.config
WebForm1.aspx

6) Double-click on Global.asax. You get to the Design view of
Global.asax. This is a place where you're supposed to add components,
I guess, but I've never used it this way. Type F7 or choose "Code" in
the "View" menu.

7) That's it!!! This is where you wanted to be since the beginning. At
this point, have a glass of champagne, it's on me!!

8) Add a new function below the existing subs:

Shared Function TextFeed()
Return "Hello global shared world"
End Function

9) Double-click on Webform1.aspx in the Solution Explorer. This takes
you to the design view of that page.

10) There is a toolbox tab somewhere (you'll get used to it very
quickly, but it can be a little unsettling at the beginning : tabs
everywhere, pinned to the left, docked to the right...). Click on it,
make sure the "Web Forms" subtab is selected, click on "Label" and
drag that to the page, anywhere. Just leave it's properties at their
default.

11) Type F7 or click on "Code" in the View menu.

12) A default stub is already in here. You have a Page_Load sub, which
is executed when the... page loads, yes. Inside this sub, just type :
Label1.Text = Global.TextFeed

13) Type F5 or choose "Run" in the Debug menu (could be "Start"
instead of "Run", not quite sure). This opens your default browser and
shows the Webform1.aspx page that you created. If everything went
well, it should show "Hello global shared world" somewhere in the
middle of it.

The Shared Function you created in the Global class is indeed global
to the application, that is, all pages and classes that it contains.
It is also static, which means that it is shared by all instances of
that application (which instantiates itself everytime a user logs onto
your site).

Be aware that, whereas Global.asax has two different views (Design and
Code), aspx pages have three (Graphical Design mode, HTML Design mode,
and Code).

If anything is still unclear, please ask.

Have fun!

Michel
 
T

tshad

Hi Michel,

As you can see I am getting started with the VS and Classes. I will play
with your list this weekend to get it down. I actually have played with VS
for Visual Basic 6, so I have an idea how it works. I just haven't got down
to playing with it to get the ins and outs.

Thanks,

Tom
 
T

tshad

Hi Michel,

I just started doing your list. And had a question.

fd123456 said:
Hi Tom!

Here is a somewhat standard procedure to achieve what you're looking
for.

As you will see, the "Visual" in "Visual Studio" will save you a lot
of time/hassles.

I will assume that you have never used any version of VS.

1) Launch VS. Create a Solution (File / New / New Solution). In the
Dialog that appears, just type a name, don't choose "Visual Basic
Projects" just yet. Let's call it TomSolution. Click OK.

2) Show the Solution Explorer window by choosing that option in the
View menu (I guess it's called View, my version isn't an english one,
third menu anyway).

3) Right-click on the Solution name in the Solution Explorer window,
and click "Add / Add new project".

4) In the dialog that appears, you can now choose "Visual Basic
Projects". Then choose "ASP.Net Web Application" in the icon list on
the right. Give it a name - TomApp - and click OK. In fact, you're not
giving a name, but the full path of the web app, in this case,
"http://localhost/TomApp".

It won't let me put in a name, but will allow me to change the location, as
you mention and then the name changes. I assume this is how it is done.
5) After a few seconds, a default project is created. The Solution
Explorer shows a list of new items :
TomApp (the project)
References (a folder)
AssemblyInfo.vb
Global.asax
Styles.css
Web.config
WebForm1.aspx

6) Double-click on Global.asax. You get to the Design view of
Global.asax. This is a place where you're supposed to add components,
I guess, but I've never used it this way. Type F7 or choose "Code" in
the "View" menu.

7) That's it!!! This is where you wanted to be since the beginning. At
this point, have a glass of champagne, it's on me!!

Had my glass. Where do I send the bill :)
8) Add a new function below the existing subs:

Shared Function TextFeed()
Return "Hello global shared world"
End Function

9) Double-click on Webform1.aspx in the Solution Explorer. This takes
you to the design view of that page.

10) There is a toolbox tab somewhere (you'll get used to it very
quickly, but it can be a little unsettling at the beginning : tabs
everywhere, pinned to the left, docked to the right...). Click on it,
make sure the "Web Forms" subtab is selected, click on "Label" and
drag that to the page, anywhere. Just leave it's properties at their
default.

11) Type F7 or click on "Code" in the View menu.

12) A default stub is already in here. You have a Page_Load sub, which
is executed when the... page loads, yes. Inside this sub, just type :
Label1.Text = Global.TextFeed

13) Type F5 or choose "Run" in the Debug menu (could be "Start"
instead of "Run", not quite sure). This opens your default browser and
shows the Webform1.aspx page that you created. If everything went
well, it should show "Hello global shared world" somewhere in the
middle of it.

I tried that, but got an error:

"Error while trying to run object: Unable to start debugging on the web
server. Debugging failed because integrated Windows authentication is not
enabled. Click help for more information."

My other pages run, why not VS?

Thanks,

Tom
 
T

tshad

Also, I can't find a "code" view in the View menu and can't find anything
that has an F7 shortcut on it.

I tried opening up one of my current pages and it show the code, but I can't
find a way to see how it looks in a design mode. There must be one (I would
assume), similar to the one you had me put the label on.

This is an aspx page. I wanted to see how the asp.net objects are rendered
inside VS.

Thanks,

Tom
 
T

tshad

tshad said:
Also, I can't find a "code" view in the View menu and can't find anything
that has an F7 shortcut on it.

I tried opening up one of my current pages and it show the code, but I
can't find a way to see how it looks in a design mode. There must be one
(I would assume), similar to the one you had me put the label on.

This is an aspx page. I wanted to see how the asp.net objects are
rendered inside VS.

I just looked at the page you had me open and it does show code,designer,
(html source or design) plus a couple of others. It then it goes to
Solution Explorer. It appears that if you open a page created outside of
VS, it won't give you a design view. The view menu starts at Solution
Explorer.

Also, what is Web Browser at the bottom of the View menu for. I assumed it
would open your page in a browser, but it just opens the
http://msdn.microsoft.com/ site.

Thanks,

Tom
 
F

fd123456

Hi Tom,

Let me try to answer your last 3 messages (sorry for being late, I
only browse the groups when I get the chance).
It won't let me put in a name, but will allow me to change the location, as
you mention and then the name changes. I assume this is how it is done.

It is. The idea behind it being that when you specify a location and a
name for the folder, it becomes a physical directory in your
c:\Inetpub\wwwroot\ folder, and also a web application of that same
name, pointing to that directory.
Where do I send the bill :)

(e-mail address removed) ! :p
I tried that, but got an error:

"Error while trying to run object: Unable to start debugging on the web
server. Debugging failed because integrated Windows authentication is not
enabled. Click help for more information."

My other pages run, why not VS?

Oh, this is one of the things that's quite difficult to set up at the
beginning, but once you get it right, you forget all about it. Guess
what? I forgot all about it. IIRC, it's about giving the debugger
enough permissions to attach itself to the IIS process. Try this :

- Somewhere on your computer is something called "IIS Internet
Services". Your best bet would be Control Panels/Administrative
tools/IIS Internet Services (it might have a slightly different name,
my XP is not an english one). And I'm not quite sure where it is
because I moved it. Try and locate it, and launch it.

- It shows a tree, like this :
IIS Internet Services
+ Name of your computer
+ Web sites
+ Default Web Site
+ IIS Help
+ _vti_bin
+ printers
...
+ TomApp (if you called it that, obviously)

- Right-click on TomApp. Choose the Folder Security tab. In "Anonymous
connections...", click on "Change". In the dialog box that shows up,
all the way down is a checkbox "Windows integrated authentification".
Check it, OK, OK, you should be good to go.
Also, I can't find a "code" view in the View menu and can't find anything
that has an F7 shortcut on it.

I tried opening up one of my current pages and it show the code, but I can't
find a way to see how it looks in a design mode. There must be one (I would
assume), similar to the one you had me put the label on.

This is an aspx page. I wanted to see how the asp.net objects are rendered
inside VS.

I think I know what the problem is. You probably imported or copied
your own pages into the solution/project/web folder. But when you
create an aspx page from *inside* VS, it does a lot of stuff : it sets
up and creates the corresponding code-behind file, plus a .resx files
that contains definitions for numerous things, like handles for object
and stuff. To be honest, the .resx file is not something I'd like to
dwell into. I've had a glimpse of it, once or twice, and very quickly
decided I'd never come back, and never did.

So, the problem is that, as you didn't create the page from inside VS,
the code-behind page hasn't been created and so you don't get the Code
menu. If I were you, I'd create a page in VS, then delete it's content
and *paste* the content of your own page, rather than copying the page
into the folder. Then you'll have all options available.
I just looked at the page you had me open and it does show code,designer,
(html source or design) plus a couple of others. It then it goes to
Solution Explorer. It appears that if you open a page created outside of
VS, it won't give you a design view. The view menu starts at Solution
Explorer.

Exactly. I hadn't tested this, but you're confirming what I suspected.
It's all about what VS does for you. The other thread you created
(where everyone is speaking for or against code-behind, which makes a
very interesting read, btw) highlights the fact that code-behind is -
I think - the way to go when you use VS, and not at all the way to go
when you don't because VS does an awful lot of stuff to ease your work
: it creates code to initialize the controls when you just drag'n'drop
them on the html editor in design view (you can see this when you go
to Code View and unfold the "Web Form Designer generated code"
section, even more impressive when you start using the DataAdapter
objects, the amount and quality of generated code is absolutely
amazing), handles the session-persistent objects, handles the events,
postback mechanisms, and so on. It really cuts down the amount of
coding you have to do. So, again, go the VS way all the way, trying to
compromise between VS-automated and "manual" modes will only bring
frustration. Even when I said "paste in the code of your own page", I
should have said : "restart your page from scratch in VS". It appears
to be a waste of time, but in the end, I'm quite confident it'll save
you a lot of time. Plus it will give you a chance to "practice". As
you've got a background with VS6, you'll get up to speed in no time.
Also, what is Web Browser at the bottom of the View menu for. I assumed
it would open your page in a browser, but it just opens the
http://msdn.microsoft.com/ site.

It's only an embedded browser. If you call it this way (from the View
menu), it takes you to the msdn site because that's the default
startup page (must be an option somewhere in the prefs), but you can
also call it by right-clicking on a page in html design view and
clicking on "Show in browser". You also have an url bar that appears,
which you can use to surf anywhere. I guess it's all about having a
self-contained IDE, but you can just use Explorer or any other
browser, to the same effect. I believe that when you test your project
with F5, the default behavior is to launch an external Explorer
windows. On a fast machine, either solution is the same, speed-wise. I
just never use the internal browser. But that's just me.

I understand your project is already 30-ish pages. I realize it could
be a hassle to start over from scratch, but I'm not sure there's an
alternative. IMHO, trying to paste bits of it will only take more
time, lead to confusion, the controls won't be properly initialized...
Anyway, it's your choice. Try both ways.

HTH,

Michel
 
K

Kevin Spencer

(e-mail address removed) ! :p

Haven't ever seen that email address, but it could work. The one that is
known is (e-mail address removed).

--
;-),

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
T

tshad

Michel,

Thanks for the info.

I think I will probably use VS to build classes (such as myUtils that are
not page specific) and Globals.asax, but as you say trying to use my other
pages in VS would be quite difficult. I am sure I would have the same
problem if I went from VS to DW.

I will probably look at using code-behind to allow someone to do some of the
design, but I will probably not compile it. I'll know better once I have
worked with it more.

Thanks for all the help,

Tom.
 
F

fd123456

Kevin, are you implying that He doesn't know how to use email aliases?
Oh, ye of little faith... :)

Michel
 
F

fd123456

You're absolutely welcome, Tom.

Proceed as you feel. In the end, if you manage to grab a non-demo
version of VS, I'm quite sure you'll put DW where it belongs : the
fond memories shelf.

By the way, the site that helped me the most when I started asp.net is
http://www.asp.net/tutorials/quickstart.aspx. You might want to check
it.

Have fun !

Michel
 
K

Kevin Spencer

Hey, I said it COULD work! ;-)

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
T

tshad

fd123456 said:
You're absolutely welcome, Tom.

Proceed as you feel. In the end, if you manage to grab a non-demo
version of VS, I'm quite sure you'll put DW where it belongs : the
fond memories shelf.

I don't thinks so. But I expect to use both. I don't use a lot of DW's
features because I don't want to be locked into it's proprietary way of
doing things (same as VS). Just from looking at both (granted I just
started with VS), I like DW much better for working with the Design side.
Also, even in DW I tend to work in the Code page and write (or copy and
paste) my objects instead of using DW's wizards to add the objects to the
page. I tend to be a more hands on type of person.

Even with using Word and DW, I use Textpad (editor) to do some of my stuff.

Each has it's own features I like.
By the way, the site that helped me the most when I started asp.net is
http://www.asp.net/tutorials/quickstart.aspx. You might want to check
it.

I will look at it.

Thanks,

Tom
 
T

tshad

As an aside, I looked at the MS ASP.Net site you mentioned and all the
samples I looked at were code-beside.

Why?

Because it is easier to read.

Remember, one of the arguments for code-behind was that it was easier to
read. I just thought it was interesting that MS chose to use code-beside
for its tutorials :)

Tom
 
F

fd123456

I believe they're code-beside because of the MS policy to provide "a
full development solution for free", meaning that you *can* write
programs for the .net platform for free using only Notepad if you
want. So, those examples cater for both types of users.

Again, my view on this is that if you own VS and are using it
properly, you can code several times faster and work on very very
complex projects (N-tier, security, auto-reconfigurable, the works),
where code is more important (in size) than design. It's not a matter
of coding practice or design, or programming quality, or even
programmer quality, it's just a matter of using a fantastic IDE that
grows on you. You can write macros and assign keystrokes to them,
which means you can type method or properties stubs in one keystroke.

The hassle of maintaining two different files for each page disappears
with VS, because going from one to the other is completely handled by
VS, as is the creation of all necessary bits of code, like
"codebehind=myPage.aspx.vb" or "inherits=myPage.vb". Note that I
originally started by writing Windows programs, not Internet ones.
Hence VS.

But I am fully aware, contrarily to some here, that my love is
threefold : I love .net because of the richness of the libraries, I
love c# for it's sheer beauty and I love VS as an IDE for the ease of
use.

At the very start of this thread - a month ago, can you believe it? -
you asked some questions about the structure of the pages for asp.net,
so I decided to share my passion for asp.net with you. In no way am I
going to force you into loving c# or the IDE, that's entirely up to
you, although at one point I had to explain what was the relation
between a page and it's codebehind because the example I had provided
was written with the IDE.

You seem to be rather intent on using DW and Textpad to code, and
there's nothing wrong with that on my end. I'll try my best to provide
you with examples you can use.

I'm not saying all this to you in particular, because I think you
understand all this already, but to those who would be tempted to
force you into practices you don't want. Maybe I should have posted
this in the other thread. Oh well.

All the best,

Michel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top