在文本框上按F7弹出供应商选择对话框,双击回填供应商名称
2004-09-14 18:12
232 查看
//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 onclick="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(",,,");
}
}
}
//[*/***]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 onclick="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(",,,");
}
}
}
相关文章推荐
- 点击文本框时弹出单选(或复选)对话框,选择选项后在文本框中显示
- Excel VBA 获取指定路径下的图片名称(带后缀)/(不带后缀)/跳出选择路径对话框手动选择路径
- 弹出对话框,选择一个文件夹,返回文件夹path
- 看杭电APP之头像选择弹出对话框(Dialog)
- 文本框双击事件弹出模态窗口接收返回值
- 如何做类似于F7的弹出选择界面?
- C#+Emgucv通过点击按钮弹出选择文件对话框
- VC弹出"选择文件"和"选择文件夹"对话框(转)
- 选择下拉框"其他" 弹出一个文本框
- VC弹出“选择文件夹”对话框的程序的编写
- 关于EAS BOS 双击消息中心弹出对话框提示 获取的单据编辑界面不正确,请检查元数据等,造成打不开流程审批界面问题
- MFC中弹出选择文件夹的对话框 BROWSEINFO 的用法
- asp.net页面中弹出对话框 选择“确定”后实现事件回调
- C#弹出选择对话框的程序
- 近期.NET学习及项目开发整理-弹出对话框显示 是否 然后得到 选择的结果
- C#弹出选择对话框的程序
- web弹出确认对话框,要有取消选择项
- window.open打开子页面,并选择回填的数据到父页面,替换了div弹出层的形式
- win7 所有EXE文件双击不能直接打开,弹出打开方式对话框
- SHBrowseForFolder弹出的选择文件夹对话框改变默认title