如题? 谢谢了~~急

解决方案 »

  1.   

    <%@ Control Language="c#" AutoEventWireup="false" Codebehind="ServiceChooser.ascx.cs" Inherits="Tencent.ITIL.ItilRequest.ItilRequestWeb.UserControl.ServiceChooser" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
    <%@ Register TagPrefix="ajax" Namespace="MagicAjax.UI.Controls" Assembly="MagicAjax" %>
    <script>
    /**//*
            function openDialog3(srcW,srcH,srcU,sl) 
            {    
                var X=0;
                var Y=0;
                var Cstyle;
                X=(screen.width-srcW)/2;
                Y=(screen.height-srcH)/2;
                Cstyle = "dialogLeft:"+X+"px;dialogTop:"+Y+"px;dialogHeight:"+srcH+"px;dialogWidth:"+srcW+"px;help:no;status:no;scroll:"+sl;
                var sReturnVal = window.showModalDialog(srcU,window,Cstyle);
                return sReturnVal;
            }
            */
            function GetValue(postback)
            {
                //目前已经选中的值
                var selectedValues = document.getElementById("<%=hdId.ClientID%>").value;
                var params = "";
                if(selectedValues != "" && selectedValues != ";")
                {
                    params = "id=" + selectedValues;
                }
                
                var url = "../Web/ServiceSelector.aspx";
                if(params != "")
                {
                    url += "?" + params;
                }
                var result = openDialog2('550','400',url,'no');
                
                
                var oldId = document.getElementById("<%=hdId.ClientID%>").value;
                if(result)
                {
                    var serviceIds = result[0];
                    var serviceNames = result[1];
                    document.getElementById("<%=hdId.ClientID%>").value = serviceIds;
                    document.getElementById("<%=txtName.ClientID%>").value = serviceNames;                
                    
                }
                            
                //var attr = document.getElementById("<%=this.ClientID%>").getAttribute("AutoPostback");            
                
                
                if(postback.toLowerCase() == "true" && oldId != document.getElementById("<%=hdId.ClientID%>").value)
                {
                    __doPostBack('<%=txtName.ClientID%>','');
                }
                
            }
    </script>
    <ajax:ajaxpanel id="Ajaxpanel1" runat="server">
      <asp:textbox id="txtName" ReadOnly="True" runat="server" Width="180px"></asp:textbox>
    </ajax:ajaxpanel>
    &nbsp;
    <IMG style="CURSOR: hand" onclick="GetValue('<%=AutoPostBack%>');" src="/tof_client/images/addrbook.gif"> 
    <INPUT id="hdId" type="hidden" name="hdId" runat="server">
    ----------------
    //....
    public bool AutoPostBack
            {
                get
                {                
                    return txtName.AutoPostBack;
                }
                set
                {
                    txtName.AutoPostBack = value;
                }
            }
    public event System.EventHandler SelectedChanged;//....private void txtName_TextChanged(object sender, System.EventArgs e)
            {
                SelectedChanged(null,null);
            }