LeftList.aspx
<%@ Page language="c#" Inherits="ItsWeb.Relation.LeftList" CodeFile="LeftList.aspx.cs" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title>LeftList</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<link rel="stylesheet" href="../Css/normal.css">
<script language="javascript">
function lstClick(){
if(Form1.lstLeft.selectedIndex==-1)
return;
var src=Form1.hdnTree.value+"&LeftRowID="+Form1.lstLeft.options[Form1.lstLeft.selectedIndex].value;
window.parent.relRight.document.location.href=encodeURI(src);
}
</script>
</head>
<body bgcolor="#95b1ef" leftmargin="2" topmargin="10" rightmargin="0">
<form id="Form1" method="post" runat="server">
<TABLE id="Table1" cellSpacing="0" cellPadding="0" width="100%" border="0">
<TR>
<TD>
<asp:Label id="lblCaption" runat="server">Label</asp:Label></TD>
</TR>
<TR>
<TD><SELECT style="WIDTH: 144px; HEIGHT: 600px" size="25" id="lstLeft" name="lstLeft" runat="server">
<OPTION></OPTION>
</SELECT></TD>
</TR>
<TR>
<TD>
                    <asp:TextBox ID="UserBox" runat="server" Width="90px" OnTextChanged="UserBox_TextChanged"></asp:TextBox>                    
                    <asp:Button ID="BtnUser" runat="server" Text="搜 索" OnClick="BtnUser_Click" /></TD>                    
</TR>
</TABLE>
<INPUT id="hdnTree" type="hidden" runat="server">
</form>
</body>
</html>LeftList.aspx.CS
 using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using ItsWeb.Common;
using ItsWeb.Dict;namespace ItsWeb.Relation
{
/// <summary>
/// LeftList 的摘要说明。
/// </summary>
public partial class LeftList : System.Web.UI.Page
{
int nTblID;
int nListTblID;

protected void Page_Load(object sender, System.EventArgs e)
{
            if (!this.IsPostBack)
            {                this.lstLeft.Attributes.Add("onchange", "return lstClick()");
                nTblID = int.Parse(Request.QueryString["nTblID"]);
                string cStruct = Request.QueryString["cStruct"];
                string[] a = cStruct.Split(';');
                string[] aa = a[0].Split(',');
                if (aa.Length != 2)
                    this.writeError("关系信息错误,没有指定列表ID");
                this.nListTblID = int.Parse(aa[1]);
                System.Data.DataRow rTbl = StaticInfo.getTableInfoRow(this.nListTblID);                if (rTbl == null)
                    this.writeError("没有找到列表信息");                bool bKeyMapBit = (bool)rTbl["bKeyMapBit"];                this.lblCaption.Text = rTbl["cCaption"].ToString() + "列表";                string sql = "nRelateToTblID=" + this.nListTblID.ToString() + " AND nTblID=" + this.nTblID.ToString();
                System.Data.DataRow[] rs = StaticInfo.dFieldDir.Select(sql);
                if (rs.Length == 0)
                {
                    CommWebUI.writeClient(this, StaticInfo.dFieldDir);
                    this.writeError("找不到联系字段信息<br>" + sql + "<br>");
                }
                // string sql=TableInfo.getSelectSql(this.nListTblID,true,true,false,this.Session);
                int nFkTblID = -1;
                sql = TableInfo.getSelectSql((int)rs[0]["nFldID"], StaticInfo.getSession(this.Application, this.Session.SessionID, false), ref nFkTblID);
                System.Data.DataTable dt = SqlConn.getDataTableOfAll(sql, nFkTblID);                string cFld = TableInfo.getListFieldAlias(rTbl);
                string cKey = rTbl["cKeyFields"].ToString();
                this.lstLeft.Items.Clear();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    int j = (int)dt.Rows[i][cKey];
                    if (bKeyMapBit)
                        j = 1 << (j - 1);
                    this.lstLeft.Items.Add(new ListItem(dt.Rows[i][cFld].ToString(), j.ToString()));
                }
                aa = a[1].Split(',');
                string right;
                if (aa[0].ToLower() == "tree")
                    right = "RightTree.aspx";
                else
                right = "RightList.aspx";
                right += "?nTblID=" + aa[1];
                right += "&RelationID=" + this.nTblID.ToString();
                right += "&LeftTblID=" + this.nListTblID.ToString();
                right += "&nModuleID=" + this.cModuleID;
                this.hdnTree.Value = right;
            }
}
private void writeError(string err)
{
Response.Write(err);
Response.End();
}
private string cModuleID
{
get
{
if(Request.QueryString["nModuleID"]==null)
return "0";
return Request.QueryString["nModuleID"];
}
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{     }
#endregion
        protected void BtnUser_Click(object sender, EventArgs e)
        {
            string cStruct = Request.QueryString["cStruct"];
            string[] a = cStruct.Split(';');
            string[] aa = a[0].Split(',');
            if (aa.Length != 2)
            this.writeError("关系信息错误,没有指定列表ID");
            this.nListTblID = int.Parse(aa[1]);            string lstLeft = " ";
            string UserSearch = this.UserBox.Text;
            System.Data.DataRow rTbl = StaticInfo.getTableInfoRow(this.nListTblID);
            string cFld = TableInfo.getListFieldAlias(rTbl);
            string cKey = rTbl["cKeyFields"].ToString();
            string sql = "select * from y_person where cNum='" + UserSearch.ToString() + "'";
            System.Data.DataTable dt = SqlConn.getDataTableOfSys(sql);
            this.lstLeft.Items.Clear();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                int j = (int)dt.Rows[i][cKey];
                this.lstLeft.Items.Add(new ListItem(dt.Rows[i][cFld].ToString(), j.ToString()));
            }
            this.lstLeft.Value = lstLeft;
        }
        protected void UserBox_TextChanged(object sender, EventArgs e)
        {        }
}
}
错误1“ItsWeb.Relation.LeftList”并不包含“UserBox”的定义

解决方案 »

  1.   

    把 UserBox  先从页面里删除  在 把 拖一个在页面里  你试一下
      

  2.   

    <asp:Label   id= "lblCaption "   runat= "server "> Label </asp:Label> 
    <asp:TextBox   ID= "UserBox "   runat= "server "   Width= "90px "   OnTextChanged= "UserBox_TextChanged "> </asp:TextBox>
    <asp:Button   ID= "BtnUser "   runat= "server "   Text= "搜   索 "   OnClick= "BtnUser_Click "   />
    id="XXX",runat="server"
    去掉里面的空格