搜索
写经验 领红包
 > 动物

弹出模式窗口返回值怎么设置(弹出式窗口怎么设置)

导语:弹出模式窗口,返回值

对话框的两种类型:模态类型和非模态类型,今天我们讲一下弹出一个模式的窗口,然后再父页面中接收模式窗口传回的返回值。话不多说直接上代码,供大家参考:

js 代码:

function show(txtHsCodeID,txtStoreNameID,txtHsCodeID2)

{

//txtHsCode为

//item为textobx1的ID,ID为Textbox2。ID

var value = document.getElementById(txtHsCodeID).value;

//window.alert(value);

var modalReturnValue;//模式的返回值

modalReturnValue=window.showModalDialog('../FrmHSCode.aspx?HsCode='+value+ '&StoreNameID='+txtStoreNameID+'&HsCodeID='+txtHsCodeID+'&HsCodeID2='+txtHsCodeID2);

// k=window.showModalDialog('../FrmHSCode.aspx?name='+value+'&ID='+ID+"&ID1="+item);

//modalReturnValue.onFocus();

if(modalReturnValue!=null)

{

var arry = new Array();

arry = modalReturnValue.split(",");//一般返回一个字符串,用斗号分割

document.getElementById(txtHsCodeID2).value =arry[0];//hs编码textbox获取的值

document.getElementById(txtStoreNameID).value=arry[1];//商品名称货物的值

}

return false;

}

if (e.Row.RowIndex > -1)

{

HtmlInputText txtHsCode1 = e.Row.FindControl("txtHsCode1") as HtmlInputText;

HtmlInputText txtStoreName = e.Row.FindControl("txtStoreName") as HtmlInputText;

HtmlInputText txtHsCode2 = e.Row.FindControl("txtHsCode2") as HtmlInputText;

HtmlInputText txtType = e.Row.FindControl("txtType") as HtmlInputText;//规格内型

HtmlInputText txtAmount = e.Row.FindControl("txtAmount") as HtmlInputText;//数量

HtmlInputText lblKg = e.Row.FindControl("lblKg") as HtmlInputText;//单位

HtmlInputText txtCargoMoney = e.Row.FindControl("txtCargoMoney") as HtmlInputText;//单价

DropDownList drpMoneyType = e.Row.FindControl("drpMoneyType") as DropDownList;//币制

HtmlInputText txtWeight = e.Row.FindControl("txtWeight") as HtmlInputText;//总量

LinkButton lnkCheck =e.Row.FindControl("lnkCheck") as LinkButton;

lnkCheck.Attributes.Add("onclick", "return show('" + txtHsCode1.ClientID + "','" + txtStoreName.ClientID + "','"+txtHsCode2.ClientID+"')");

//LB1.Attributes.Add("onclick", "show('" + txt1.ClientID + "','" + txt2.ClientID + "')");

Button btn = e.Row.FindControl("btnDelete") as Button;

//重写功能

btn.Attributes.Add("onclick", "reset('" + txtHsCode1.ClientID + "','" + txtStoreName.ClientID + "','" + txtHsCode2.ClientID + "','" + txtType.ClientID + "','" + txtAmount.ClientID + "','" + lblKg.ClientID + "','" + txtCargoMoney.ClientID + "','" + drpMoneyType.ClientID + "','" + txtWeight.ClientID + "')");

}

<script language="javascript" type="text/javascript">

function show(hsCode,storeNameID,hsCodeValue,storeNameValue)

{

window.returnValue = hsCodeValue+","+storeNameValue;//主意一定要用这个了,和open返回不一样了;

window.close();

}

</script>

if (e.Row.RowIndex > -1)

{

e.Row.Attributes.Add("ondblclick", "show('" + hsCodeID2 + "','" + storeNameID + "','" + e.Row.Cells[0].Text + "','" + e.Row.Cells[1].Text + "')");

//e.Row.Attributes.Add("ondblclick", "show('" + e.Row.Cells[0].Text + "','" + e.Row.Cells[1].Text + "')");

}

本文内容由小舻整理编辑!