请教:关于combobox 第一次点击自动收回 各位老师和朋友: 我做的带有combobox窗体控件挂到网页上,运行程序进入该控件窗体页面,点击combobox自动收回。如果先点击其他,该combobox使用正常。请各位老师和朋友不吝赐教!谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 从没遇到过,仔细看看html代码看看有什么问题。 借用别人写的一段代码填充combobox: public class ComboBoxItem { private string _text=null; private object _value=null; public string Text{get{return this._text;} set{this._text=value;}} public object Value{get {return this._value;} set{this._value=value;}} public override string ToString() { return this._text; } } 在控件的load事件中: DataTable t_bumen=new DataTable(); SqlDataAdapter my_ada=new SqlDataAdapter("select id,BuMenMing from BuMenBiao ",sqlConnection1); my_ada.Fill(t_bumen); sqlConnection1.Close(); for(int i=0;i<t_ZhanSuo.Rows.Count;i++) { ComboBoxItem newItem = new ComboBoxItem(); newItem.Text=t_bumen.Rows[i]"BuMenMing"].ToString(); newItem.Value=t_bumen.Rows[i]["id"].ToString(); cob_gds.Items.Add(newItem); } 这个ComboBox是否有PostBack?在网页加载的时候有没有用!Page.IsPostBack? 估计是js的问题,你看看执行后生成的html代码 在网页上挂控件的代码如下:<HTML> <HEAD> <title>BuMen_INFO</title> <META http-equiv="Content-Type" content="text/html; charset=gb2312"> <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1"> <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1"> <meta name="vs_defaultClientScript" content="JavaScript"> <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"> </HEAD> <body MS_POSITIONING="GridLayout" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0"> <form id="Form1" method="post" runat="server" scroll="yes"> <OBJECT id="Flow" height="100%" width="100%" classid='Http://<%@ Page Language="vb"%><%=System.Configuration.ConfigurationSettings.AppSettings.Item("OcxPath")%>/BuMen_INFO.dll#BuMen_INFO.BuMen_INFO' VIEWASTEXT></OBJECT> <script language=javascript>Form1.Flow.BuMen_INFO_Load();</script><br> </form> </body></HTML> Form1.Flow.BuMen_INFO_Load();这个里面有没有使用ispostback之类的东西?看看有没有问题 Wpf项目如何调用WinForm项目的自定义控件 关于C#的装箱拆箱问题 C#中,如何用OpenGL把图像绘制在Form上?? 错在哪里啊? c#中如何调用读卡器里的外部函数呢? 组件拖动与增删效果,求达人建议 PrintDialog 为什么不能用selection 功能。 c# 正则表达式获取数据问题 c#函数声明的问题 如何在客户端送出命令,在服务端执行? windows 控件参数传递的问题? 请问各位,.net开发用哪种报表好?
public class ComboBoxItem
{
private string _text=null;
private object _value=null;
public string Text{get{return this._text;} set{this._text=value;}}
public object Value{get {return this._value;} set{this._value=value;}}
public override string ToString()
{
return this._text;
}
}
DataTable t_bumen=new DataTable();
SqlDataAdapter my_ada=new SqlDataAdapter("select id,BuMenMing from BuMenBiao ",sqlConnection1);
my_ada.Fill(t_bumen);
sqlConnection1.Close();
for(int i=0;i<t_ZhanSuo.Rows.Count;i++)
{
ComboBoxItem newItem = new ComboBoxItem();
newItem.Text=t_bumen.Rows[i]"BuMenMing"].ToString();
newItem.Value=t_bumen.Rows[i]["id"].ToString();
cob_gds.Items.Add(newItem);
}
<HTML>
<HEAD>
<title>BuMen_INFO</title>
<META http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<form id="Form1" method="post" runat="server" scroll="yes">
<OBJECT id="Flow" height="100%" width="100%" classid='Http://<%@ Page Language="vb"%><%=System.Configuration.ConfigurationSettings.AppSettings.Item("OcxPath")%>/BuMen_INFO.dll#BuMen_INFO.BuMen_INFO' VIEWASTEXT></OBJECT>
<script language=javascript>Form1.Flow.BuMen_INFO_Load();</script><br>
</form>
</body>
</HTML>