.NET 自定义控件完成输入内容模糊检索功能,现在可以检索但不能自动提交
各位.NET高手们,我这里有一个问题,写了一个自定义控件,但是,不自动提交,谁能帮我修改一下啊,我是初学者,实在不知道问题的所在了,由于代码太长,就不往上贴了,如果有能够帮我的,加我QQ吧, 我给发过去,在这里非常感谢了,实在是愁了我一天啊。我QQ271690197 --------------------编程问答-------------------- http://www.jzxue.com/wangzhankaifa/asp-net/201208/07-13475.html控件类必须实现IPostBackDataHandler接口,并实现LoadPostData和RaisePostDataChangedEvent方法。 --------------------编程问答-------------------- 嗯,我明白,但是就是这个我不会用的,你能把你的邮箱告诉我,我给你发过去,你帮我看一下吧,在网上找了一个高手,他帮我写了一半,但是他现在忙了,我是明白,但是不知道怎么写的,就差自动提交了 --------------------编程问答-------------------- 可不可以呢,我是则接触.NET不久的,拜托… --------------------编程问答-------------------- 大神哪谁来救救我哪,无奈原码附上,不自动提交,哪里有问题啊,自定义控件的代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class CustomerDropDown : System.Web.UI.UserControl, IPostBackDataHandler
{
protected void Page_Load(object sender, EventArgs e)
{
//this.TextBox1.TextChanged+=new EventHandler(TextBox1_TextChanged);
}
/// <summary>
/// 原始列表框的数据源
/// </summary>
public Object DataSource
{
get
{
return this.ListBox1.DataSource;
}
set
{
this.ListBox1.DataSource = value;
}
}
/// <summary>
/// 原始数据的绑定成员
/// </summary>
public String DataMember
{
get
{
return this.ListBox1.DataMember;
}
set
{
this.ListBox1.DataMember = value;
}
}
/// <summary>
/// 原始数据的绑定字段
/// </summary>
public String DataTextField
{
get
{
return this.ListBox1.DataTextField;
}
set
{
this.ListBox1.DataTextField = value;
}
}
/// <summary>
/// 列表
/// </summary>
public ListItemCollection Items
{
get
{
return this.ListBox1.Items;
}
}
/// <summary>
/// 选中项的索引
/// </summary>
public int SelectedIndex
{
get
{
return this.ListBox1.SelectedIndex;
}
set
{
this.ListBox1.SelectedIndex = value;
}
}
/// <summary>
/// 选中值
/// </summary>
public object SelectedValue
{
get
{
return this.ListBox1.SelectedValue;
}
}
/// <summary>
/// 输入框的值
/// </summary>
public String Text
{
get
{
return this.TextBox1.Text;
}
set
{
this.TextBox1.Text = value;
}
}
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
//这个地方写自己的引用事件从程序
if (OnTextChangeCustomer != null)
{
OnTextChangeCustomer(sender, e);
}
}
//public delegate void OnChangeCustomer(Object s,EventArgs e );
public event EventHandler OnTextChangeCustomer;
public bool LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection)
{
// throw new NotImplementedException();
string postedValue = postCollection[postDataKey];
string PresentValue = Text;
if (PresentValue == null || postedValue != PresentValue)
{
Text = postedValue;
return true;
}
return false;
}
//public bool AutoPostBack
//{
// get
// {
// }
//}
public void RaisePostDataChangedEvent()
{
// throw new NotImplementedException();
OnTextChangeCustomer(null , EventArgs.Empty);
}
}
补充:.NET技术 , C#