放在Page_Load()里
TextBox1.Attributes.Add("onclick","Get_value()");
javascript:
function Get_value()
{
var tmp_value;
tmp_value=showModalDialog("setvalue.aspx","","")
document.你的form.TextBox1.value=tmp_value;
}
-------------
setvalue.aspx
html:
<script language="javascript">
window.returnValue=你的返回值
window.opener =null;
window.close();
</script>
----------------------------------------------------
如果你要在弹开的子窗口中给父窗口赋值的话,用下面代码就可以了
window.dialogArguments.document.all.txtboxid.value = "返回的值";
---------------------------------------------------------------------------------------------------------
//对话框返回信息
//btn是执行 是 操作的Button的id,btn1是执行 否 操作的Button的id
void Confirm(string str_Message,string btn,string btn1,Page page)
{
page.RegisterStartupScript("","<script> if (confirm('"+str_Message+"')==true){document.forms(0)."+btn+".click();} else{ document.forms(0)."+btn1+".click(); }</script>");
}
private void Button1_Click(object sender, System.EventArgs e)
{
Response.Write("覆盖操作");
}
private void Button2_Click(object sender, System.EventArgs e)
{
Response.Write("新增操作");
}
//调用
Confirm("是否要覆蓋原來的記錄?","Button1","Button2",Page);