|
-
Jul 8th, 2006, 12:13 PM
#1
Thread Starter
Fanatic Member
[Resolved] <% %> vs <script runat=server>
I finally decided to migrate from ASP to .NET, so you will see me here quite often. 
Anyway, what I'm trying to understand is the difference between the
<% %> tags vs <script runat=server>
It seems like both methods work identical. Furthermore, when I create a function in <script> tags I can then access it in the <% %>
What is the difference? Which one should I be using?
Thank you!
------------------
After doing a few google searches i found this at
velocityreviews.com/forums
Craig Deelsnyder
Posts: n/a
Default Re: <script language="vb" runat=server> versus <% %>
[email protected] wrote:
> Pardon the newbie question...
>
> What's the difference between (asp.net)VB code inside one versus the
> other. And why have both?
There is no difference, assuming your app's default language (set in the
page or web.config) is set to VB. The second one is shorthand for the
first, it'll assume the default language of your app (or page)....I
recommend using the former though for clarity as the latter was more of
an ASP legacy notation, which I don't know if it's frowned upon using
now....
--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Last edited by invitro; Jul 8th, 2006 at 03:59 PM.
Reason: Spelling, format, and a resolution yay!
ok, so... windows takes 1 minute to search for a file on my PC yet google.com takes 1 second to search the entire internet? 
-
Jul 9th, 2006, 05:31 AM
#2
-
Jul 10th, 2006, 04:02 AM
#3
Fanatic Member
Re: [Resolved] <% %> vs <script runat=server>
<% %> - This is a method call and can activate Subs, Functions or Events
<runat="server"> - This is so that a form object (such as a textbox, button) will have associated server-side events.
 Life is one big rock tune 
-
Jul 11th, 2006, 03:37 PM
#4
Re: [Resolved] <% %> vs <script runat=server>
Yes I'm still here, and how did he bring you back, is he a wizard?
-
Jul 12th, 2006, 03:36 PM
#5
Thread Starter
Fanatic Member
Re: [Resolved] <% %> vs <script runat=server>
What I am doing is a Database class for my own website. Everything happens behind the scenes in a CS file, I only use <% to call and create objects and then use them on my pages.
This is just a basic sample of how I am doing this.
Code:
<%
Connection.Database objDatabase = new Connection.Database();
SqlDataReader sqlReader = null;
sqlReader = objDatabase.GetAllUsers();
if(sqlReader != null)
{
while(sqlReader.Read())
{
Response.Write(sqlReader[0]);
}
}
sqlReader.Close();
objDatabase.CloseConnection();
%>
Connection is a namespace and Database is the class. The Database class contains functions that call stored procedures, which I then use in my ASPX website.
Judging by your response I think I'm on the right track.
Thanks a lot for your help guys.
Yes I'm still here, and how did he bring you back, is he a wizard?
Lots of death threats
Last edited by invitro; Jul 12th, 2006 at 03:52 PM.
Reason: My horrid spelling
ok, so... windows takes 1 minute to search for a file on my PC yet google.com takes 1 second to search the entire internet? 
-
Jul 12th, 2006, 04:35 PM
#6
Re: [Resolved] <% %> vs <script runat=server>
I wouldn't say you're on the right track. You're still sticking to the old ASP 3.0 style of coding. You can use the Page Load event to create the objects and use them as you will.
Want an ASP.NET tutorial?
By the way, google takes about 1 second to search the Internet because it stores its results on a large arrayed network after hours of crawling web servers.
-
Jul 12th, 2006, 05:49 PM
#7
Thread Starter
Fanatic Member
Re: [Resolved] <% %> vs <script runat=server>
A tutorial would be awsome. I need to get out of the habbit of coding in ASP and move towards ASP .NET.
What I don't get is how I'm suppose to manipulate that code in a CS file and then pass it to the aspx page without actually manipulating the data in the aspx file. I hope the tutorial answers that.
Again thanks for the help.
PS: I knew someone was going to spring the google trap.
ok, so... windows takes 1 minute to search for a file on my PC yet google.com takes 1 second to search the entire internet? 
-
Jul 15th, 2006, 06:28 AM
#8
Re: [Resolved] <% %> vs <script runat=server>
This is the one I link most:
http://samples.gotdotnet.com/quickstart/aspplus/
And remember, when learning ASP.NET, let go of the old Classic ASP habits. They are now bad. Most of them anyways.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|