如果你把所有的c#代码写在HTML页面就可以!他指定了你的后台类。
解决方案 »
- 自动功能
- 请问谁知道ASPxNavBar是否具有记忆功能?
- TabContainer 刷新父页面
- 请教各位高人一个ASP.NET和 JS 的问题
- gridview里checkbox问题
- asp.net的面试题
- ASP.NET用SQL命令问题????
- DataSet里可以存多少条记录。
- 蛙蛙请教:form验证模式,用户在登陆和注销时都引发什么事件呀?
- 怎样动态改变泛型变量存储的数据,然后绑定到repeater上?
- 咱们中国的程序员同胞们,有没有谁写出超强的DataGrid的?在这里大家交流一下!使中国的DataGrid再前进一步!
- 再来:datagrid自定义分页,在oracle下rownum的使用!!
<%@ Page Language="c#" CodeBehind="test_conn_hyl.aspx.cs" AutoEventWireup="true" Inherits="***.***"%>这句怎么改,然后c#语句用什么标签括起来。
快帮帮我吧,我把代码拷过来是这样的:
<%@ Page Language="c#" AutoEventWireup="false" %>
........
<%
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;namespace conn{
public class conn : System.Web.UI.Page {
protected System.Web.UI.WebControls.TextBox Name;
public conn() {
Page.Init += new System.EventHandler(Page_Init);
}
private void Page_Load(object sender, System.EventArgs e) {
// Put user code to initialize the page here
SqlConnection myCon = new SqlConnection("server=localhost;uid=sa;pwd=;database=store");
SqlDataReader myRead ;
SqlCommand myCom = new SqlCommand("select * from customers",myCon);
if (myCon.State == ConnectionState.Closed) myCon.Open();
myRead = myCom.ExecuteReader(CommandBehavior.CloseConnection);
Name.value=myRead["fullname"];
Response.Write("ok");
} private void Page_Init(object sender, EventArgs e) {
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
} #region Web Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
this.Load += new System.EventHandler(this.Page_Load); }
#endregion
}
}
%>
前面省略了html代码,编译出错:
Compiler Error Message: CS1513: } expectedSource Error:Line 20: using System.Web.UI;
Line 21: using System.Web.UI.WebControls;
Line 22: using System.Web.UI.HtmlControls;
Line 23:
Line 24: namespace conn{
如果你采用代码后置就必须要写。
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.ComponentModel" %>
................
<script runat="server">
void Page_Load(Object sender, EventArgs e)
{
// Put user code to initialize the page here
SqlConnection myCon = new SqlConnection("server=localhost;uid=sa;pwd=;database=store");
SqlDataReader myRead ;
SqlCommand myCom = new SqlCommand("select * from customers",myCon);
if (myCon.State == ConnectionState.Closed) myCon.Open();
myRead = myCom.ExecuteReader(CommandBehavior.CloseConnection);
Name.value=myRead["fullname"];
Response.Write("ok");
}
</script>
照你说的改了,还是不行,虽然编译不出错了,但是没有结果,我在page_load事件里加了些简单的测试语句,包括response.write("....."),可是毫无反应。