cs文件中
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;namespace WebApplication3
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Ajax.Utility.RegisterTypeForAjax(typeof(WebForm1));
this.TextBox2.Attributes.Add("onchange", "itemResult();"); //this.TextBox1.Attributes.Add("ondblclick", "popweb()");
} #region GetItemList
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)]
public DataSet GetItemList(string item)
{
DataSet ds = new DataSet();
ds.Tables.Add();
ds.Tables[0].Columns.Add("name", typeof(string)); ds.Tables[0].Rows.Add("a12345");
ds.Tables[0].Rows.Add("a12346");
ds.Tables[0].Rows.Add("a22347");
ds.Tables[0].Rows.Add("b12345");
ds.Tables[0].Rows.Add("b22345");
return ds;
}
#endregion
}
}
aspx文件中
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication3.WebForm1" %><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
<title></title>
<script language="javascript" type="text/javascript">
function popweb() {
//window.open("webForm2.aspx","newweb","height=500,width=800");
window.open("webForm2.aspx");
} function itemResult() {
var item = document.getElementById("TextBox2").value;
alert(item);
WebForm1.GetItemList(item, get_item_Result_CallBack);
} function get_item_Result_CallBack(response) {
if (response.value != null) {
var ds = response.value; if (ds != null && typeof (ds) == "object" && ds.Tables != null) {
if (ds.Tables[0].Rows.length > 0) {
document.getElementById("ddlItem").style.display = "Item";
document.getElementById("ddlItem").length = 0;
} for (var i = 0; i < ds.Tables[0].Rows.length; i++) {
var name = ds.Tables[0].Rows[i].item;
document.getElementById("ddlItem").options.add(new Option(name));
}
}
}
else {
document.getElementById("ddlItem").style.display = "none";
}
return
} </script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Button" />
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<span style="position: absolute; border-left: yellowgreen 1px solid; border-top: yellowgreen 1px solid; border-right: yellowgreen 1px solid">
<asp:ListBox Style="display: none" ID="ddlItem" runat="server" CssClass="formBaseFont" Width="200px"
Rows="5"></asp:ListBox></span>
</div>
</form>
</body>
</html>
运行的时候提示
错误: “WebForm1”未定义
自己写的一个非常非常简单的画面,但就是怎么也解决不聊,
目的就是在textbox2中输入“a",自动将a开头的记录匹配出来,各位可以新建一个webform的程序,将代码拷贝过去就可以运行了,请教各位大神该怎么解决啊,谢谢,万分感激!!
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;namespace WebApplication3
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Ajax.Utility.RegisterTypeForAjax(typeof(WebForm1));
this.TextBox2.Attributes.Add("onchange", "itemResult();"); //this.TextBox1.Attributes.Add("ondblclick", "popweb()");
} #region GetItemList
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)]
public DataSet GetItemList(string item)
{
DataSet ds = new DataSet();
ds.Tables.Add();
ds.Tables[0].Columns.Add("name", typeof(string)); ds.Tables[0].Rows.Add("a12345");
ds.Tables[0].Rows.Add("a12346");
ds.Tables[0].Rows.Add("a22347");
ds.Tables[0].Rows.Add("b12345");
ds.Tables[0].Rows.Add("b22345");
return ds;
}
#endregion
}
}
aspx文件中
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication3.WebForm1" %><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
<title></title>
<script language="javascript" type="text/javascript">
function popweb() {
//window.open("webForm2.aspx","newweb","height=500,width=800");
window.open("webForm2.aspx");
} function itemResult() {
var item = document.getElementById("TextBox2").value;
alert(item);
WebForm1.GetItemList(item, get_item_Result_CallBack);
} function get_item_Result_CallBack(response) {
if (response.value != null) {
var ds = response.value; if (ds != null && typeof (ds) == "object" && ds.Tables != null) {
if (ds.Tables[0].Rows.length > 0) {
document.getElementById("ddlItem").style.display = "Item";
document.getElementById("ddlItem").length = 0;
} for (var i = 0; i < ds.Tables[0].Rows.length; i++) {
var name = ds.Tables[0].Rows[i].item;
document.getElementById("ddlItem").options.add(new Option(name));
}
}
}
else {
document.getElementById("ddlItem").style.display = "none";
}
return
} </script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Button" />
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<span style="position: absolute; border-left: yellowgreen 1px solid; border-top: yellowgreen 1px solid; border-right: yellowgreen 1px solid">
<asp:ListBox Style="display: none" ID="ddlItem" runat="server" CssClass="formBaseFont" Width="200px"
Rows="5"></asp:ListBox></span>
</div>
</form>
</body>
</html>
运行的时候提示
错误: “WebForm1”未定义
自己写的一个非常非常简单的画面,但就是怎么也解决不聊,
目的就是在textbox2中输入“a",自动将a开头的记录匹配出来,各位可以新建一个webform的程序,将代码拷贝过去就可以运行了,请教各位大神该怎么解决啊,谢谢,万分感激!!
解决方案 »
- 指定的参数已超出有效值的范围。
- 请问remoting的代理,能够拦截private方法吗?
- 老问题..gridview手动分页!!
- js 占用CPU的问题
- 关于gridview中的控件取值问题??急。。
- 如何用一个事件打开和关闭一个网页
- 网站不能访问数据asp.net2.0+mssql2005 为将对象应用到对象的实例
- 有没有人需要用服务器的?我有一台想托管,大家共用,找几个人分摊一下!!!
- DropDownList控件数据绑定的问题?
- “未能加载类型“Enviroment.kehuleixing.Leixing”会是错在什么地方呢?
- 求大佬解答
- ashx的参数值如何传到index4.aspx中.cs……。在线等急,请高手帮忙
webconfig中如果在<system.web>加入
<httpHandlers>
<add verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandlerFactory, Ajax" />
</httpHandlers>
程序直接报错
HTTP Error 500.23 - Internal Server Error
检测到在集成的托管管道模式下不适用的 ASP.NET 设置。
.......