Inline Coding Model in ASP.NET using VB.NET

In this article you will learn about Inline Coding Model.
  • 2831
 

Introduction

In this article I am discussing inline coding model in. In inline coding model business logic appears in <script></script> block in the .aspx page itself. When first time the page loads it compiles into a class that resides in an assembly stored in a subfolder of "c:\windows\Microsoft.Net\FrameWork\v4.x.xxxx\temporaryasp.net files" folder. This compiled version of the page is good untill the .aspx file changes or the application is restarted. At that time it will have to be recompiled.


Getting started

  • Simply create a new ASP.NET web application. 
  • Drag two labels, one Textbox and a Button control on page. The page will look like below.

    Inline1.gif
     
  • Then attach the below code.

    <%@ Page Title="Home Page" Language="vb"  AutoEventWireup="false"
        CodeBehind="Default.aspx.vb" Inherits="ModeEncode._Default" %>
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <script runat="server">
        Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
            Label1.Text = "Your Friend Name: " & TextBox1.Text.ToString()
        End Sub
    </script>
    <
    html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Asp.Net Inline Coding Model Example</title>
    </head>
    <
    body>
        <form id="form1" runat="server">
        <div>
            <asp:Label ID="Label1" runat="server" Font-Size="Larger" ForeColor="Crimson"></asp:Label>
            <br />
            <asp:Label ID="Label2" runat="server" Text="Friend Name" AssociatedControlID="TextBox1"></asp:Label>
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            <br />
            <asp:Button ID="Button1" runat="server" Text="Click Me" OnClick="Button1_Click" />
        </div>
        </form>
    </body>
    </
    html>
     
  • Now run your application.

     

Output:-

Inline2.gif

Inline3.gif

Inline4.gif

Summary

In this article you learned how you can build Inline Coding Model.

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.