Register Register Member Login Member Login Member Login Forgot Password ??
PHP Tutorial (Hypertext Preprocessor), ASP Tutorial (Active Server Pages), ASP.NET Tutorial (.Net 1.1,2.0,3.5)
   
   
  Registered : 70,205
   
 
HOME > ASP.NET > ASP.NET HTML & Form > ASP.NET & HTML
Search

ASP.NET & HTML

 
 
 
ASP.NET & HTML ในภาษา ASP.NET สามารถแรก HTML ได้โดยตรงเหมือนกับภาษา PHP หรือ ASP ครับ ซึ่งผมจะแยกออกเป็น 2 ประเด็นคือ

Language Code : VB.NET || C#

1. เขียนในรูปแบบของ ASP Style

การเขียนในรูปแบบของ ASP Style คือการเขียนที่บรรจุดส่วนของ HTML และในส่วนของ ASP.NET Code ไว้ในไฟล์เดียวกัน ซึ่งสามารถพัฒนาได้บน Tool ทั่ว ๆ ไป เช่น Edit plus,Notepad,WebMatrx หรือ Macromedia Dreamweaver


MyFile.aspx (VB.NET)

<%@ Page Language="VB" %>
<%
Response.write ("This is ASP Tag")
%>
<script runat="server">
    Sub Page_Load()
        Me.txtName.Text = "This is ASP.NET Tag"
    End Sub
</script>
<html>
<head>
</head>
<body>
    <form runat="server">
        <%
        Response.write("This is ASP Tag<br>")
        %>
        <asp:Label id="lblText" runat="server" text="Text"></asp:Label>
        <asp:TextBox id="txtName" runat="server"></asp:TextBox>
    </form>
</body>
</html>


ASP.NET HTML



2. เขียนในรูปแบบของ Code-Behind Style

เป็นรูปแบบการเขียน Code ที่แยกในส่วนของ HTML และส่วนของ ASP.NET Code ไว้คนล่ะไฟล์ โดยส่วนของ HTML Form จะถูกจัดเก็บไว้ที่ .aspx และส่วนของ ASP.NET Code จัดเก็บไว้ที่ .asp.vb (VB.NET) หรือ .aspx.cs (C#) สำหรับ Tool ที่ใช้พัฒนาได้แก่โปรแกรม Visual Studio .NET 2003 และ Visual Studio 2005 หรือ Visual Studio 2008


ตัวอย่างการเขียนด้วย (VB.NET)

MyWebPage.aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="MyWebPage.aspx.vb" Inherits="MyWebPage" %>

<!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" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="lblText" runat="server"></asp:Label>
        <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
	</div>
    </form>
</body>
</html>


MyWebPage.aspx.vb

Public Class MyWebPage
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Me.lblText.Text = "Name"
        Me.txtName.Text = "Mr.Weerachai Nukitram"

    End Sub
End Class


Screenshot

ASP.NET HTML


WebMatrix

Visual Studio .NET 2003

Visual Studio 2005,2008




 

ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท

 
  By : ThaiCreate.Com Team (บทความเป็นลิขสิทธิ์ของเว็บไทยครีเอทห้ามนำเผยแพร่ ณ เว็บไซต์อื่น ๆ)
  Score Rate :  
  Create/Update Date : 2008-10-27 23:08:27 / 2009-06-02 16:38:37
  View : 3,275
  Download : No files
   
 
Sponsored Links
 
 
Ads Contact : 08-1987-6107
Download Mozilla Firefox
 
Ads Contact : 08-1987-6107
 Sponsored Links
ASP.NET runat="server"
Rate : View : 2,502
ASP.NET Tag Form
Rate : View : 2,105
ASP.NET Web Control & HTML Control
Rate : View : 2,340
 
 
© www.ThaiCreate.Com. 2003-2009 All Rights Reserved. My network : ThaiGoodWeb.Com , DVDmono.com
Comments & Suggestions Please Contact Us : thaicreate at hotmail dot com [Conditions Privacy Statement] ติดต่อโฆษณา 01-987-6107 อัตราราคา คลิกที่นี่