Using inline code in ASP.NET (C# and VB.Net)






Using this syntax, you can use inline code in ASP.NET (.aspx) pages. The server-side code will be automatically compiled by the .NET framework the first time the page is requested on the server. The compiled .dll file is stored in the "Temporary ASP.NET Files" system folder. Changing the code in .aspx files will trigger a new compilation, generating new .dll files. The old .dll files are phased out by the framework and eventually deleted.

Example

C#


<%@ Import Namespace="System" %>
<%@ Page Language="c#"%>

<script runat="server">
  public string ServerSideFunction(string input)
  {
    return "Hello " + input;
  }
</script>

<% string pageVariable = "world"; %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<title>ASP.NET inline</title>
</head>
<body>
<% =ServerSideFunction(pageVariable) %>
</body>
</html>

VB.Net


<%@ Import Namespace="System" %>
<%@ Page Language="VB" %>

<script runat="server">
  Public Function ServerSideFunction(input As String) As String
    ServerSideFunction = "Hello " & input
  End Function
</script>

<% Dim pageVariable As String = "world" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<title>ASP.NET inline</title>
</head>
<body>
<% =ServerSideFunction(pageVariable) %>
</body>
</html>

Share this

Previous
Next Post »

1 comments:

comments
Anonymous
March 27, 2022 at 1:40 AM delete

Using Inline Code In Asp.Net (C And Vb.Net) - Complete .Net Tutorial >>>>> Download Now

>>>>> Download Full

Using Inline Code In Asp.Net (C And Vb.Net) - Complete .Net Tutorial >>>>> Download LINK

>>>>> Download Now

Using Inline Code In Asp.Net (C And Vb.Net) - Complete .Net Tutorial >>>>> Download Full

>>>>> Download LINK

Reply
avatar