zoukankan      html  css  js  c++  java
  • TextBox 内容由弹出窗口选择返回的实现

    在项目中很多时候Textbox 需要有弹出窗口来选择返回.这里简单介绍实现方式.

    1.新建弹出选择窗口页面:

    前台:

    代码
                <TABLE width="100%" align="center">
                    
    <tr>
                        
    <td class="td" align="center">
                            
    <asp:TextBox id="txtSearchLike" runat="server" Width="254px"></asp:TextBox><asp:button id="btnSelect" runat="server" Width="70px" CssClass="button" Text="Select"></asp:button></td>
                    
    </tr>
                    
    <tr>
                        
    <td class="td" align="center" colSpan="2"><asp:listbox id="lbxResult" runat="server" Width="325px" Height="136px" SelectionMode="Multiple"></asp:listbox></td>
                    
    </tr>
                    
    <tr>
                        
    <td class="td" align="center">
                            
    <asp:button id="btnConfirm" runat="server" Width="70px" CssClass="button" Text="Confirm"></asp:button></td>
                    
    </tr>
                
    </TABLE>

    后台:

    代码
            private void btnSelect_Click(object sender, System.EventArgs e)
            {
                
    try
                {
                    
    string SearchLike = this.txtSearchLike.Text.Trim();
                    
    string col=Request.QueryString["SearchLike"];  //参数传入
                    string org=Request.QueryString["org"];
                    BindListBox(SearchLike,col,org);
                }
                
    catch(Exception ex)
                {

                }
            }
            
    public void BindListBox(string SearchLike,string col,string org)
            {
                
    try
                {

                    ListBox 内容绑定
                }
                
    catch(Exception ex)
                {

                }
            }

    private void btnConfirm_Click(object sender, System.EventArgs e)
            {
                
    try
                {
                    
    string strScript="";
                    
    string rtnValue="";
                    
                    
    for(int i=0;i<this.lbxResult.Items.Count;i++)
                    {
                        
    if(this.lbxResult.Items[i].Selected)
                        {                           
                            
    string valueSelected=this.lbxResult.Items[i].Value;

                            
    if(valueSelected!="")
                            {
                                rtnValue 
    += this.lbxResult.Items[i].Value + ",";
                            }
                        }
                    }
                    
    if(rtnValue=="")
                    {
                        
                        rtnValue
    =",";
                        
                    }

                    strScript 
    = "<script language = javascript>" +
                        
    "dialogArguments[0].value = '" + rtnValue.Remove(rtnValue.Length-1,1).Trim() + "';" +    
                        
    "window.close();" +
                        
    "</script>";   //返回值
                    RegisterClientScriptBlock("e",strScript);
                    
    return;
                }
                
    catch(Exception ex)
                {

                }
            }

    页面使用:

    前台: Textbox

    <asp:textbox id="txtOrg" Runat="server" ReadOnly="True"></asp:textbox><input id="btnOrg" onclick="return GetOrgInfo();" type="button" value="V" name="btnOrg" runat="server">

    JS:

      function GetOrgInfo()
      {
      
       var colname = "org";
       var url = "SearchForSupply.aspx?SearchLike="+colname+"&"+new Date().getTime()+"&org=";
       window.showModalDialog(url,[document.getElementById("txtOrg")],'dialogWidth:400px;dialogHeight:300px;status:no;help:no;scroll:no;menubar:no;resizable:yes');
      
       return true;
      }

  • 相关阅读:
    linq to access 简单实现 实例demo
    FCKEDITOR中文使用说明 js调用
    asp.net mvc 随想
    fccms 小型简单个人blog源码
    PHP文件上传路径
    前端优化技巧(一)
    会话框拖拽效果实现
    phpmailer配置
    上传图片动态预览(兼容主流浏览器)
    Java将多个list对象根据属性分组后合并成一个新的集合
  • 原文地址:https://www.cnblogs.com/andycai/p/1696952.html
Copyright © 2011-2022 走看看