<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %> .Net Asp

.Net ASP:

Document: ASP.NET Outline

ASP.NET Code:

A. ASP Code:

1.input.html file:

<html>
<head>
<title>Dynamic Forms</title>
</head>
<body>
<H2>Using Forms and Asp</H2>
<Form method="post" action="/mysite/process.asp">
Enter your first name: <input type="text" size="30" name="fname"><p></p>
Enter your last name: <input type="text" size="30" name="lname"><p></p>
<input type="submit" value="Process this!">
</Form>
</body>
</html>

Process.asp or Process.aspx file:

<html>
<head>
<title>Final Results</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<%@language=VBscript%>
<%
Dim first, last
first =request.querystring("fname")
last = request.querystring("lname")
%>

</head>
<body>
Your name is <%=first%><%=last%>
</body>
</html>

2. Database Retrieve:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="file:///C|/inetpub/wwwroot/MySite/Connections/strConn.asp" -->
<%
Dim new1
Dim new1_numRows
Set new1 = Server.CreateObject("ADODB.Recordset")
new1.ActiveConnection = MM_strConn_STRING
new1.Source = "SELECT * FROM table1"
new1.CursorType = 0
new1.CursorLocation = 2
new1.LockType = 1
new1.Open()

new1_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = 10
Repeat1__index = 0
new1_numRows = new1_numRows + Repeat1__numRows
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<strong>Database Retrieve</strong>
<table border="1">
<tr>
<td>firstname</td>
<td>lastname</td>
</tr>
<% While ((Repeat1__numRows <> 0) AND (NOT new1.EOF)) %>
<tr>
<td><%=(new1.Fields.Item("firstname").Value)%></td>
<td><%=(new1.Fields.Item("lastname").Value)%></td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
new1.MoveNext()
Wend
%>
</table>
</body>
</html>
<%
new1.Close()
Set new1 = Nothing
%>
-----------

strConn.asp file(include):

<%
' FileName="Connection_odbc_conn_dsn.htm"
' Type="ADO"
' DesigntimeType="ADO"
' HTTP="false"
' Catalog=""
' Schema=""
Dim MM_strConn_STRING
MM_strConn_STRING = "dsn=new1;"
%>

---------------------------------

a: new1.mdb access database file with test1 table.


ADO(active X data objects): 7objects: connection, recordset, field, property, error, command, parameter.
------------------------------

Another one:

1. input.htm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form action="http://localhost/mysite/process3.asp" method="put" >
<p>
<input name="fname" type="text" size="20" maxlength="20">
</p>

<p>
<input name="submit" type="submit">
<input name="reset" type="reset">
</p>
</form>

</body>
</html>

2.insertprocess.asp

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/s1.asp" -->
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<%
Dim first
first=request.QueryString("fname")
set Command1 = Server.CreateObject("ADODB.Command")
Command1.ActiveConnection = ("dsn=note;") %>
<%
Command1.CommandText = "INSERT INTO table1 VALUES ('" & first & "' )"
Command1.CommandType = 1
Command1.CommandTimeout = 0
Command1.Prepared = true
%>
</head>
<body>
<%=first%>
<%
Command1.Execute()
%>
</body>
</html>

3. Another code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form action="http://localhost/mysite/process3.asp" method="put" >
<p>
Title: <input name="title" type="text" size="30">
</p>
<p><font color="#0000FF" size="5"><strong>Notes:(20 Lines or less per submit)</strong></font>
<textarea name="fname" rows="13" cols="100" wrap="soft"></textarea>
</p>
<p>
<input name="submit" value="Submit Notes" type="submit" >
<input name="reset" type="reset">
</p>
</form>
</body>
</html>

-------

<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/new1.asp" -->
<%
title1 = "hello"
title = request.querystring("title")
first=request.QueryString("fname")
set Command1 = Server.CreateObject("ADODB.Command")
Command1.ActiveConnection = MM_new1_STRING
Command1.CommandText = "INSERT INTO Table1 (title,firstname) VALUES ('" & title & "', '" & first & "')"
Command1.CommandType = 1
Command1.CommandTimeout = 0
Command1.Prepared = true
Command1.Execute()
Command1.CommandText = "UPDATE Table1 Set title = '" & title1 & "' where firstname = '1234'"
Command1.Execute()
%>
<html>
<head>
</head>
<body>
<%=first%> <%=title%>
</body>
</html>


B. ASP.NET Code:

1.Basic code: play.aspxCtrls,version=1.0.0.0,publicKeyToken=836f606ede05d46a,culture=neutral"

--------------------------------

<html>
<head>
<title>Updating a price</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script runat="server">
dim name as string
sub btnSubmit_Click(Sender As Object, e AS EventArgs)
name=txtHello.text
lblHello.visible=True
DataBind()
End Sub
</script>
</head>
<body>
<asp:label id="lblHello" visible="false" runat="server">
Hello, <%# name%>!
</asp:label>
<form runat="server">
<asp:textbox ID="txtHello" ReadOnly="false" runat="server" Text=" " TextMode="SingleLine" >
</asp:textbox>
<br/>
<br/>
<asp:button ID="btnSubmit" OnClick="btnSubmit_Click" runat="server" Text="submit" />
</form>
</body>
</html>
lcome to my website and hope you to enjoy it!

-------------------------------------

2.DB code basic

<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<%@ Register TagPrefix="MM" Namespace="DreamweaverCtrls" Assembly="DreamweaverCtrls,version=1.0.0.0,publicKeyToken=836f606ede05d46a,culture=neutral" %>
<MM:DataSet
id="DataSet1"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_new1") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_new1") %>'
CommandText='<%# "select * from table1;" %>'
Debug="true" PageSize="2"
> </MM:DataSet>
<MM:PageBind runat="server" PostBackBind="true" />
<html>//*<%@ Register TagPrefix="MM" Namespace="DreamweaverCtrls" Assembly="DreamweaverCtrls,version=1.0.0.0,publicKeyToken=836f606ede05d46a,culture=neutral" %>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form runat="server">

<asp:DataGrid id="DataGrid1"
runat="server"
AllowSorting="False"
AutoGenerateColumns="false"
CellPadding="3"
CellSpacing="0"
ShowFooter="false"
ShowHeader="true"
DataSource="<%# DataSet1.DefaultView %>"
PagerStyle-Mode="NextPrev"
AllowPaging="true"
AllowCustomPaging="true"
PageSize="<%# DataSet1.PageSize %>"
VirtualItemCount="<%# DataSet1.RecordCount %>"
OnPageIndexChanged="DataSet1.OnDataGridPageIndexChanged"
>
<HeaderStyle HorizontalAlign="center" BackColor="#E8EBFD" ForeColor="#3D3DB6" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Bold="true" Font-Size="smaller" />
<ItemStyle BackColor="#F2F2F2" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Size="smaller" />
<AlternatingItemStyle BackColor="#E5E5E5" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Size="smaller" />
<FooterStyle HorizontalAlign="center" BackColor="#E8EBFD" ForeColor="#3D3DB6" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Bold="true" Font-Size="smaller" />
<PagerStyle BackColor="white" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Size="smaller" />
<Columns>
<asp:BoundColumn DataField="firstname"
HeaderText="firstname"
ReadOnly="true"
Visible="True"/>
<asp:BoundColumn DataField="lastname"
HeaderText="lastname"
ReadOnly="true"
Visible="True"/> </Columns>
</asp:DataGrid>
</form>
</body>
</html>

C: PHP/MYSQL Code:

<?php require_once('Connections/ccc.php'); ?>
<?php
mysql_select_db($database_ccc, $ccc);
$query_Recordset1 = "SELECT * FROM employee";
$Recordset1 = mysql_query($query_Recordset1, $ccc) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<em><font color="#FF0000" size="4"><strong>init and name:</strong></font></em> <br>
<?php do { ?>
<strong><font color="#0000FF"><?php echo $row_Recordset1['init']; ?></font></strong>: <strong><?php echo $row_Recordset1['lastname']; ?></strong> <br>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>

</body>
</html>
<?php
mysql_free_result($Recordset1);
?>

---------------

PS: 1. use iis; 2. download php windows version, 3.download mysql windows version.4.run dreamweaver.

include file code:

<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_ccc = "localhost";
$database_ccc = "chang1";
$username_ccc = "csi";
$password_ccc = "";
$ccc = mysql_pconnect($hostname_ccc, $username_ccc, $password_ccc) or die(mysql_error());
?>



© Exchange Professional
Tel:782.982.2857
http://www.cs.csi.cuny.edu/~chang