ASP.NET 팝업 창에서 정보를 선택하는 몇 가지 방법

11035 단어 개인 수필
 ASP.NET ,            ,            ,     ,     。

위 그림은 단일 선택, 즉 먼저 창을 팝업하고 정보를 선택한 후 팝업 창을 닫은 다음 원래 페이지에서 필요한 팝업 데이터 컨트롤 내용을 선택한 내용으로 설정합니다.
 
위 그림은 팝업 창을 팝업한 후 원하는 정보를 선택한 후 팝업 창의 원래 페이지에서 팝업 창 정보를 가져올 컨트롤을 닫지 않는 여러 가지 선택입니다.
구체적인 코드는 다음과 같습니다.
원래 페이지:

/*  toid      ID,     ID,toname textbox,       。         ,     JAVASCRIPT  */
function group_select(toid,toname)
{
	var url= "../../../module/group_select/index.aspx?ToId="+toid+"&ToName="+toname; 
	var mwidth = "400";
	var mheight = "330";
	var loc_x,loc_y;  
	if(window.navigator.appName.toLowerCase().indexOf("netscape") > -1)
	{
		loc_x = parseInt((document.body.clientWidth - mwidth)/2) + 200;
		loc_y = parseInt((document.body.clientHeight - mheight)/2);	
		window.open(url,"group_select","left=" + loc_x + "px,top=" + loc_y + "px,width=" + mwidth + "px,height=" + mheight + "px,resizable=no,scrollbars=yes,status=0");
	}
	else
	{
		loc_x=document.body.scrollLeft+event.clientX-event.offsetX-100;
		loc_y=document.body.scrollTop+event.clientY-event.offsetY+170;
		window.showModalDialog(url,self,"edge:raised;scroll:1;status:0;help:0;resizable:1;dialogWidth:"+mwidth+"px;dialogHeight:"+mheight+"px;dialogTop:"+loc_y+"px;dialogLeft:"+loc_x+"px");
	}
}


팝업 창 페이지에서 주요 코드(선택 사항):


      
    
    
var parent_window;
if(window.navigator.appName.toLowerCase().indexOf("netscape") > -1)
	parent_window = window.parent.opener;
else
	parent_window = parent.dialogArguments;
    
    
function click_place(PartID,PartName)
{
    parent_window.document.getElementById("<% = PartID   %>").value = PartID;
    parent_window.document.getElementById("<% = PartName %>").value = PartName;
    returnValue="OK";
    window.close();/*      */
}

    


    
','');">
','');">
    (  )

             var privlist=new Array(); <%=strPrivList%></code></p> <p><code class="language-html">var parent_window; if(window.navigator.appName.toLowerCase().indexOf("netscape") > -1)  parent_window = window.opener; else  parent_window = window.dialogArguments;</code></p> <p><code class="language-html">function click_priv(priv_id) {   TO_VAL=parent_window.document.getElementById("<% =ViewState["ToId"] %>").value;   TO_NAME=parent_window.document.getElementById("<% =ViewState["ToName"] %>").value;   targetelement=document.getElementById("PRIV_"+priv_id);   priv_name=targetelement.getAttribute("name");</code></p> <p><code class="language-html">  if(TO_VAL.indexOf(","+priv_id+",")>0 || TO_VAL.indexOf(priv_id+",")==0)   {     if(TO_VAL.indexOf(priv_id+",")==0)          parent_window.document.getElementById("<% =ViewState["ToId"] %>").value=parent_window.document.getElementById("<% =ViewState["ToId"] %>").value.replace(priv_id+",","");         if(TO_VAL.indexOf(","+priv_id+",")>0)           parent_window.document.getElementById("<% =ViewState["ToId"] %>").value=parent_window.document.getElementById("<% =ViewState["ToId"] %>").value.replace(","+priv_id+",",",");               if(TO_NAME.indexOf(priv_name+",")==0)            parent_window.document.getElementById("<% =ViewState["ToName"] %>").value=parent_window.document.getElementById("<% =ViewState["ToName"] %>").value.replace(priv_name+",","");               if(TO_NAME.indexOf(","+priv_name+",")>0)        parent_window.document.getElementById("<% =ViewState["ToName"] %>").value=parent_window.document.getElementById("<% =ViewState["ToName"] %>").value.replace(","+priv_name+",",",");         borderize_off(targetelement);   }   else   {     parent_window.document.getElementById("<% =ViewState["ToId"] %>").value+=priv_id+",";     parent_window.document.getElementById("<% =ViewState["ToName"] %>").value+=priv_name+",";     borderize_on(targetelement);   } }</code></p> <p><code class="language-html">function borderize_on(targetelement) {  color="#003FBF";  targetelement.style.borderColor="black";  targetelement.style.backgroundColor=color;  targetelement.style.color="white";  targetelement.style.fontWeight="bold"; }</code></p> <p><code class="language-html">function borderize_off(targetelement) {   targetelement.style.backgroundColor="";   targetelement.style.borderColor="";   targetelement.style.color="";   targetelement.style.fontWeight=""; }</code></p> <p><code class="language-html">function begin_set() {   TO_VAL=parent_window.document.getElementById("<% =ViewState["ToId"] %>").value;    if(TO_VAL=="ALL_PRIV")   {      parent_window.document.getElementById("<% =ViewState["ToId"] %>").value="";      parent_window.document.getElementById("<% =ViewState["ToName"] %>").value="";   }  </code></p> <p><code class="language-html">  for (step_i=0; step_i<privlist.length; step_i++)   {   priv_id=privlist[step_i];      if(TO_VAL.indexOf(","+priv_id+",")>0 || TO_VAL.indexOf(priv_id+",")==0)   borderize_on(document.getElementById("PRIV_"+privlist[step_i]));   } }</code></p> <p><code class="language-html">function add_all() {   TO_VAL=parent_window.document.getElementById("<% =ViewState["ToId"] %>").value;   for (step_i=0; step_i<privlist.length; step_i++)   {     priv_id=privlist[step_i];     priv_name=document.getElementById("PRIV_"+privlist[step_i]).getAttribute("name");</code></p> <p><code class="language-html">    if(TO_VAL.indexOf(","+priv_id+",")<=0 && TO_VAL.indexOf(priv_id+",")!=0)     {         parent_window.document.getElementById("<% =ViewState["ToId"] %>").value+=priv_id+",";         parent_window.document.getElementById("<% =ViewState["ToName"] %>").value+=priv_name+",";         borderize_on(document.getElementById("PRIV_"+privlist[step_i]));     }   } }</code></p> <p><code class="language-html">function add_all_priv() {  parent_window.document.getElementById("<% =ViewState["ToId"] %>").value="ALL_PRIV";     parent_window.document.getElementById("<% =ViewState["ToName"] %>").value=" ";       parent.close(); }</code></p> <p><code class="language-html">function del_all() {    for (step_i=0; step_i<privlist.length; step_i++)   {   TO_VAL=parent_window.document.getElementById("<% =ViewState["ToId"] %>").value;  TO_NAME=parent_window.document.getElementById("<% =ViewState["ToName"] %>").value;       priv_id=privlist[step_i];     priv_name=document.getElementById("PRIV_"+privlist[step_i]).getAttribute("name");      if(TO_VAL.indexOf(priv_id+",")==0)     parent_window.document.getElementById("<% =ViewState["ToId"] %>").value=parent_window.document.getElementById("<% =ViewState["ToId"] %>").value.replace(priv_id+",","");       if(TO_VAL.indexOf(","+priv_id+",")>0)      parent_window.document.getElementById("<% =ViewState["ToId"] %>").value=parent_window.document.getElementById("<% =ViewState["ToId"] %>").value.replace(","+priv_id+",",",");             if(TO_NAME.indexOf(priv_name+",")==0)       parent_window.document.getElementById("<% =ViewState["ToName"] %>").value=parent_window.document.getElementById("<% =ViewState["ToName"] %>").value.replace(priv_name+",","");               if(TO_NAME.indexOf(","+priv_name+",")>0)        parent_window.document.getElementById("<% =ViewState["ToName"] %>").value=parent_window.document.getElementById("<% =ViewState["ToName"] %>").value.replace(","+priv_name+",",",");           borderize_off(document.getElementById("PRIV_"+privlist[step_i]));   } }</code></p> <p><code class="language-html">                                                       

      

private void LoadData()
        {
            string lit = "";
            Utilities.DBConnect db = new Utilities.DBConnect();

            DataTable dt = db.ExecuteDataTable("Select * from TMobileGroup order by GID");
            if (dt == null) { return; }
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string GID = dt.Rows[i]["GID"].ToString();
                string GName = dt.Rows[i]["GName"].ToString();
                strPrivList += "privlist[" + i.ToString() + "]=" + GID + ";\r
"; lit += "\r
"; lit += "" + GName + "\r
"; lit += "\r
"; } litPriv.Text = lit; }

이것은 사도 OA의 탄창을 참고하여 만든 것이다.물건은 간단하니 더 이상 말하지 마라.
 

좋은 웹페이지 즐겨찾기