473,856 Members | 1,666 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Some easy question about ASP.NET application

Hello!

I'm new to ASP.NET application but I have been using C# windows form for one
year.

I'm reading a book about Webbdevelopment .
Below is a small ASP.NET application.
I just wonder why is it not any class like it is in the window form like
this
public class Test : Forms
{
....
}
I thought that everything must be put within a class

I created a project using template ASP.NET Web Application
then a class was created like this.
public class WebForm1 : System.Web.UI.P age
{
....
}

Now to my question :
1.So is it possible to create a ASP.NET application without putting the code
within a class. Like my ASP.NET application example below.
2.If I want to put my ASP.NET application below within a class how would it
look like then?
3.What is the difference for my ASP.NET application below if I put the code
in a class or have it as it is now without any class.
<%@ Page Language="C#" %>

<HTML>
<HEAD>
<SCRIPT RUNAT="SERVER">
protected void btnMyButton_Cli ck(object Source, EventArgs e)
{
lblMyLabel.Text = "Some <bclicked </bon the button!";
}
</SCRIPT>
</HEAD>

<BODY>
<H3>A simple webbformexample </H3>
<FORM RUNAT=SERVER>
<asp:Button id=btnMyButton
runat="server"
Text="My button"
onclick="btnMyB utton_Click" />
<br>
<br>
<asp:Label id=lblMyLabel
runat=server />
</FORM>
</BODY>
</HTML>The form upper border


Aug 15 '06 #1
2 1270
Tony Johansson wrote:
Now to my question :
1.So is it possible to create a ASP.NET application without putting the code
within a class. Like my ASP.NET application example below.
Yes.. as you did
2.If I want to put my ASP.NET application below within a class how would it
look like then?
I am guessing you are talking about Code-behind model of creating
asp.net application. And Visual Studio.Net uses the code-behind model,
as you saw from your WebForm1 example
3.What is the difference for my ASP.NET application below if I put the code
in a class or have it as it is now without any class.
The difference would be, when is the code compiled.

In code-Behind model, you compile all the code as a DLL and put it in a
bin folder and deploy. In an in-line coding, like your example below,
the code is compiled only at the time of actualy request.

and some other differences would be, clean code-separation from HTML
and also, by going with code-behind model you can protect intellectual
property, by not leaving the actual code in the aspx page, as it is
done in the inline coding

THere could be several other differences, but please do a google search
for "inline coding vs codebehind". You would find tons of literature
>

<%@ Page Language="C#" %>

<HTML>
<HEAD>
<SCRIPT RUNAT="SERVER">
protected void btnMyButton_Cli ck(object Source, EventArgs e)
{
lblMyLabel.Text = "Some <bclicked </bon the button!";
}
</SCRIPT>
</HEAD>

<BODY>
<H3>A simple webbformexample </H3>
<FORM RUNAT=SERVER>
<asp:Button id=btnMyButton
runat="server"
Text="My button"
onclick="btnMyB utton_Click" />
<br>
<br>
<asp:Label id=lblMyLabel
runat=server />
</FORM>
</BODY>
</HTML>The form upper border


begin 666 p.gif
M1TE&.#EAU0`.`) $``/___P``_P`````*( R'Y! $`````+ ````#5``X```+_
MA(^IR^T/HYRTVHNAR+P?L7E B%P1&V: C!;9?UX:KA@WV;= QXK@^\7BFI`*JA
MPG@T'9 8&2#DM#BCLP55 8E-D>=S$UC)4,A?CI? )TYDP-LMB+K;BR77/0T_ZA
MUZ/N._YYY^4C>+#U53 @8E&:&9E8DMDB4% B;$^&BT!A@'QXD@ EP#UIIGYJ6DZ
M>G78!6"8B'@Q]MAX(EF;A"!K*X22 >QJZ"7?5]N?9V=8YZG#\)M<S Z(P(Q-HS
M$0LYZQB)MIO;JW L6L^SWMR$,FD<G# A6.;B6:O* Z/?]*V-#'>/N=L,M@=%G)
MUK: IY@5"^;N("E1O^X !\X4,@;Q6]22ZJJ:MVR)>:1DG 7>/G,>$YB.]&<EIH
M#!F5E>\:VK-8;^)%C$MF]3+A#=L^6@(%@A/)KB0H/>,:JM.#[^ >H:LJSH,V
M31I&2MCZ^=P8<F "^;")*5?D*%@.WL 63+FCV+-JVV"5[#NGT+-Z[<N73KVIU1
#```[
`
end
Aug 15 '06 #2
with 2.0 there is no real difference between inline and code behind, as all
compiling is done by the aspnet_compiler . the code behind is a partial
class, so its like an include with the form code.

its just a matter of taste.

-- bruce (sqlwork.com)
"Kumar Reddi" <ku********@gma il.comwrote in message
news:11******** **************@ b28g2000cwb.goo glegroups.com.. .
Tony Johansson wrote:
>Now to my question :
1.So is it possible to create a ASP.NET application without putting the
code
within a class. Like my ASP.NET application example below.

Yes.. as you did
>2.If I want to put my ASP.NET application below within a class how would
it
look like then?

I am guessing you are talking about Code-behind model of creating
asp.net application. And Visual Studio.Net uses the code-behind model,
as you saw from your WebForm1 example
>3.What is the difference for my ASP.NET application below if I put the
code
in a class or have it as it is now without any class.

The difference would be, when is the code compiled.

In code-Behind model, you compile all the code as a DLL and put it in a
bin folder and deploy. In an in-line coding, like your example below,
the code is compiled only at the time of actualy request.

and some other differences would be, clean code-separation from HTML
and also, by going with code-behind model you can protect intellectual
property, by not leaving the actual code in the aspx page, as it is
done in the inline coding

THere could be several other differences, but please do a google search
for "inline coding vs codebehind". You would find tons of literature
>>

<%@ Page Language="C#" %>

<HTML>
<HEAD>
<SCRIPT RUNAT="SERVER">
protected void btnMyButton_Cli ck(object Source, EventArgs e)
{
lblMyLabel.Text = "Some <bclicked </bon the button!";
}
</SCRIPT>
</HEAD>

<BODY>
<H3>A simple webbformexample </H3>
<FORM RUNAT=SERVER>
<asp:Button id=btnMyButton
runat="server"
Text="My button"
onclick="btnMyB utton_Click" />
<br>
<br>
<asp:Label id=lblMyLabel
runat=server />
</FORM>
</BODY>
</HTML>The form upper border


begin 666 p.gif
M1TE&.#EAU0`.` )$``/___P``_P`````*( R'Y! $`````+ ````#5``X```+_
MA(^IR^T/HYRTVHNAR+P?L7E B%P1&V: C!;9?UX:KA@WV;= QXK@^\7BFI`*JA
MPG@T'9 8&2#DM#BCLP55 8E-D>=S$UC)4,A?CI? )TYDP-LMB+K;BR77/0T_ZA
MUZ/N._YYY^4C>+#U53 @8E&:&9E8DMDB4% B;$^&BT!A@'QXD@ EP#UIIGYJ6DZ
M>G78!6"8B'@ Q]MAX(EF;A"!K*X22 >QJZ"7?5]N?9V=8YZG#\)M<S Z(P(Q-HS
M$0LYZQB)MIO;J WL6L^SWMR$,FD<G #A6.;B6:O* Z/?]*V-#'>/N=L,M@=%G)
MUK: IY@5"^;N("E1O^X !\X4,@;Q6]22ZJJ:MVR)>:1DG 7>/G,>$YB.]&<EIH
M#!F5E>\:VK-8;^)%C$MF]3+A#=L^6@(%@A/)KB0H/>,:JM.#[^ >H:LJSH,V
M31I&2MCZ^=P8< F"^;")*5?D*%@.W L63+FCV+-JVV"5[#NGT+-Z[<N73KVIU1
#```[
`
end

Aug 15 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
13696
by: Edilmar | last post by:
Hi, First of all, I'm new in Python... I have worked with manu langs and IDEs, like Delphi, VB, JBuilder, Eclipse, Borland C++, Perl, etc... Then, today I think IDEs like Delphi have a excelent environment to develop apps with little time. I saw many people talking about Python like a easy lang to learn and to develop. But I have look at IDEs for Python, or ways
9
2945
by: sk | last post by:
I have an applicaton in which I collect data for different parameters for a set of devices. The data are entered into a single table, each set of name, value pairs time-stamped and associated with a device. The definition of the table is as follows: CREATE TABLE devicedata ( device_id int NOT NULL REFERENCES devices(id), -- id in the device
193
9692
by: Michael B. | last post by:
I was just thinking about this, specifically wondering if there's any features that the C specification currently lacks, and which may be included in some future standardization. Of course, I speak only of features in the spirit of C; something like object-orientation, though a nice feature, does not belong in C. Something like being able to #define a #define would be very handy, though, e.g: #define DECLARE_FOO(bar) #define...
6
2353
by: TPJ | last post by:
Help me please, because I really don't get it. I think it's some stupid mistake I make, but I just can't find it. I have been thinking about it for three days so far and I still haven't found any solution. My code can be downloaded from here: http://www.tprimke.net/konto/PyObject-problem.tar.bz2. There are some scripts for GNU/Linux system (bash to be precise). All you need to know is that there are four classes. (Of course, you may...
4
1858
by: Steve | last post by:
I have read a couple articles online, read my Jesse Liberty book but I am still confused as to just what the best practices are for using exceptions. I keep changing how I'm working with them and it has now, after 15k lines of code resulted in a royal mess! It's my hope to ask some specific questions with scenario examples and that some of you might offer a little guidance or general suggestions. 1) string...
0
9916
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9762
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11057
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10696
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10782
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9531
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7932
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4575
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3201
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.