ASP.NET Code
  Home arrow ASP.NET Code arrow Page 3 - ASP.NET Basics (part 2): Not My Type
Iron Speed
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
VeriSign Whitepapers 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET CODE

ASP.NET Basics (part 2): Not My Type
By: Harish Kamath (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 27
    2003-07-30

    Table of Contents:
  • ASP.NET Basics (part 2): Not My Type
  • Building Blocks
  • A New Assignment
  • Strange Characters
  • Playing The Numbers
  • Operate With Caution
  • Everything Must Go
  • Cast And Credits
  • Mixing It Up
  • It's A Wrap

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    ASP.NET Basics (part 2): Not My Type - A New Assignment


    (Page 3 of 10 )

    Now, you might not know this, but you've already seen the "string" data type in action. In the first part of this tutorial, I used the following script to introduce you to variables.


    <script language="c#" runat="server">
    void Page_Load()

    string name// define a variable as a string type
    name "Neo"// put some initial value into it
    whoami.Text "I am " name ". Welcome to my world.";

    </script>
    <html>
    <head><title>Who am I?</title></head>
    <body>
    <asp:label id="whoami" runat="server" />
    </body>
    </html>

    In this example, the variable "name" has been defined as a string, and stores the string value "Neo". As you will see, a similar technique can be used to define other types of variables also.

    There are two important operators in this example that I "conveniently" forgot to mention when I first introduced it. Now that my memory is fully restored, though, let me bring them to your attention. The first is the assignment operator, as illustrated in the snippet below:


    <%
    name "Neo"// put some initial value into it
    %>

    The assignment operator in C# scripts, like in most other languages, is the = symbol, and it's used to assign a value (the right side of the equation) to a variable (the left side). The value being assigned need not always be fixed; it could also be another variable,


    <%
    name myname
    %>

    or an expression,


    <%
    sum = (10 2) + (20 5); 
    %>

    or even an expression involving other variables


    <%
    diff temp 20
    %>

    The assignment operator will be a staple of your C# experience - nary a day will pass when you don't use it - so get used to seeing it around.

    So that takes care of the first operator - now for the second:


    <%
    whoami.Text "I am " name ". Welcome to my world.";
    %>

    You'll notice that this line of code combines three strings to form a single string. This is accomplished by using the concatenation (+) operator, whose primary job is to add strings together. You can also use it to add numbers - I'll show you that shortly.

    More ASP.NET Code Articles
    More By Harish Kamath (c) Melonfire


     

    ASP.NET CODE ARTICLES

    - How to Use the ListBox Control in ASP.NET 2.0
    - How to Load XML Documents in ASP.NET 2.0
    - DataGrid Code
    - ASP.NET Guestbook
    - User Controls and Client Side Scripting
    - ASP.NET Programming with Microsoft's AS...
    - ASP.NET Basics (part 3): Hard Choices
    - ASP.NET Basics (part 2): Not My Type
    - ASP.NET Basics (part 1): Nothing But .Net
    - Directory Tree Browser
    - How to get the confirmation of Yes/No from a...
    - Complete example using custom errors and wri...
    - Paging Certain # records per page .NET style
    - General Methods of formatting and Subtractin...
    - .NET LinkButton web control





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway