我的ASP.NET怎么不运行呢?(100分)

小乔

Unregistered / Unconfirmed
GUEST, unregistred user!
我用C#编写了一段ASP.NET程序,内容如下:
<%@ Page Language="C#"%>
<html>
<head>
</head>
<body>
<center>
<form action="intro2.aspx" method="post">
<h3>
姓名:<input id="Name" type="text"> 类别:<select id="类别" size="1">
<option>psychology</option>
<option>business</option>
<option>popular_comp</option>
</select>
</h3>
<input type="submit" value="查找">
<p>
<% for (int i=0;
i <8;
i++) { %>
<font size="<%=i%>">欢迎使用 ASP.NET </font>
<br>
<% }%>
</form>
</center>
</body>
</html>
存放为WebForm1.aspx文件,可是当我调用时,上面的<%%>里的东东却不执行,请教各位如何解决呢?
 
ASPX有这种写法么?你这是ASP的写法。
看下面这个例子:
<%@ Page Language="VB" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<script runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)

' TODO: Update the ConnectionString and CommandText values for your application
if not IsPostBack then
Dim ConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:/Source/devnet/DevDB.mdb;Persist Security Info=False"
Dim CommandText As String = "select * from publicinfo where infotype=0 order by postdate"

Dim myConnection As New OleDbConnection(ConnectionString)
Dim myCommand As New OleDbCommand(CommandText, myConnection)

myConnection.Open()

DataGrid1.DataSource = myCommand.ExecuteReader()
DataGrid1.DataBind()
end if

End Sub

Sub Grid_ItemClick(Sender As Object, E As DataGridCommandEventArgs)
dim recid as string
if E.CommandSource.CommandName = "Del" then
recid = E.Item.Cells(0).Text
Dim ConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:/Source/devnet/DevDB.mdb;Persist Security Info=False"
Dim CommandText As String = "delete from publicinfo where id=" &amp;
recid

Dim myConnection As New OleDbConnection(ConnectionString)
Dim myCommand As New OleDbCommand(CommandText, myConnection)

myConnection.Open()
myCommand.ExecuteNonQuery()
myCommand.CommandText = "select * from publicinfo where infotype=0"
DataGrid1.DataSource = myCommand.ExecuteReader()
datagrid1.DataBind
else
end if
End Sub
</script>
<html>
<head>
</head>
<body style="FONT-FAMILY: arial">
<h2>新闻-News
</h2>
<hr size="1" />
<form runat="server">
<asp:datagrid id="DataGrid1" runat="server" OnItemCommand="Grid_ItemClick" BorderColor="#3366CC" BorderWidth="1px" BorderStyle="None" PageSize="3" AutoGenerateColumns="False" AllowPaging="false" CellPadding="4" BackColor="White" Width="90%">
<FooterStyle forecolor="#003399" backcolor="#99CCCC"></FooterStyle>
<HeaderStyle font-bold="True" forecolor="#CCCCFF" backcolor="#003399"></HeaderStyle>
<PagerStyle horizontalalign="Left" forecolor="#003399" backcolor="#99CCCC" mode="NumericPages"></PagerStyle>
<SelectedItemStyle font-bold="True" forecolor="#CCFF99" backcolor="#009999"></SelectedItemStyle>
<ItemStyle forecolor="#003399" backcolor="White"></ItemStyle>
<Columns>
<asp:BoundColumn DataField="id" HeaderText="编号"></asp:BoundColumn>
<asp:BoundColumn DataField="infotitle" HeaderText="新闻标题"></asp:BoundColumn>
<asp:ButtonColumn Text="查看" HeaderText="查看" CommandName="View"></asp:ButtonColumn>
<asp:ButtonColumn Text="删除" HeaderText="删除" CommandName="Del"></asp:ButtonColumn>
</Columns>
</asp:datagrid>
<br />
<br />
<asp:Button id="Button1" runat="server" Text="添加新闻"></asp:Button>
</form>
</body>
</html>
 

Similar threads

I
回复
0
查看
734
import
I
I
回复
0
查看
623
import
I
I
回复
0
查看
2K
import
I
I
回复
0
查看
2K
import
I
I
回复
0
查看
1K
import
I
顶部