在文本框上按F7弹出供应商选择对话框,双击回填供应商名称

//asp.net+javascript

//[*/***]index.aspx
<html>
function SearchSupply(supplyName)
{
 var ret= window.showModalDialog('showsupply.aspx?pSupplyName='+supplyName,window,'scroll:no;status:no;center:yes;dialogHeight:280px;dialogWidth:480px;');
 if(ret!=null)
 {
  var newret = ret.split(",")
  document.all.txtSupplyName.value=newret[1];   
 }
}

function onhelpkeydown()
{
 if (event.keyCode==118)
 {
  var vSupplyName=document.all.txtSupplyName.value;
  event.srcElement.value="正在查询,请稍候......";
  if (event.srcElement.id=="txtSupplyName")
  {
   SearchSupply(vSupplyName);
  }
 }
}

厂家名称<asp:textbox id="txtSupplyName" runat="server" Width="216px"></asp:textbox>
</html>

//[**/**]index.aspx.cs
private void Page_Load(object sender, System.EventArgs e)
{
 txtSupplyName.Attributes["onkeydown"]="onhelpkeydown();";
}

//[***/*]showsupply.aspx
<html>
<head>
<script language="javascript">
function retvalue()
{
 window.returnValue=document.all.ListBox1.value;
 window.opener=null;
 window.close();
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
 <form id="Form1" method="post" runat="server">
  <asp:listbox id="ListBox1" runat="server" Height="216px" Width="456px"></asp:listbox>
  <DIV οnclick="javascript:window.self.close()">【关闭窗口】</DIV>
 </form>
</body>
</HTML>

//[****/]showsupply.aspx.cs
public class showsupply : System.Web.UI.Page
{
 protected System.Web.UI.WebControls.ListBox ListBox1;
 private string cnnStr=System.Configuration.ConfigurationSettings.AppSettings.Get("ConnectionString");
 
 private void Page_Load(object sender, System.EventArgs e)
 {
  string name=Request.QueryString["pSupplyName"].ToString().Trim();
  ListBox1.Attributes["ondblclick"]="retvalue();"; 
  ListBox1.Items.Clear();
  OleDbConnection cnn=null;
  OleDbCommand cmd=null;
  OleDbDataReader dataReader=null;
  string sql=null;
  sql="select supplyid,supplyname from supplys where supplyname like '%"+ name +"%'";
  cnn=new OleDbConnection(cnnStr);   
  cnn.Open();
  cmd=new OleDbCommand(sql,cnn);

  dataReader=cmd.ExecuteReader();
  while(dataReader.Read())
  {
   ListBox1.Items.Add(dataReader.GetString(0)+","+dataReader.GetString(1));
  }
  dataReader.Close();
  cmd.Dispose();
  cnn.Close();
  if(ListBox1.Items.Count<=0)
  {
   ListBox1.Items.Add(",,,");
  }
 }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值