当前位置: 代码迷 >> ASP.NET >> window.showModalDialog页面传值! 求help解决思路
  详细解决方案

window.showModalDialog页面传值! 求help解决思路

热度:5994   发布时间:2013-02-25 00:00:00.0
window.showModalDialog页面传值! 求help
js代码:function openwindow(url) {
  window.showModalDialog(url, "Sample", "fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no, copyhistory=no,width=350,height=140,left=200,top=300");
  }
通过控件给url传值
 <asp:LinkButton ID="lbtnRolePower" runat="server" CommandName="Power" OnClientClick="openwindow('<%#GetUrl()%>')" >分配权限</asp:LinkButton>

后台方法: public void GetUrl()
  {
  string url= "NewBox.aspx?RoleId=" +RoleIdToSetPower.ToString(); 
   
  }
为什么js的参数无效?

------解决方案--------------------------------------------------------
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton lbtnRolePower = e.Row.FindControl("lbtnRolePower") as LinkButton;
lbtnRolePower.OnClientClick = "NewBox.aspx?RoleId=" + DataBinder.Eval(e.Row.DataItem,"RoleIdToSetPower").ToString() + ";return false;";
}
}


RoleIdToSetPower就是你数据源中的RoleId字段名称如果不叫这个名字,自己改
------解决方案--------------------------------------------------------
参数传递:
1. 要想对话框传递参数,是通过vArguments来进行传递的。类型不限制,对于字符串类型,最大为4096个字符。也可以传递对象,例如:
-------------------------------
parent.htm
<script>
var obj = new Object();
obj.name="51js";
window.showModalDialog("modal.htm",obj,"dialogWidth=200px;dialogHeight=100px");
</script>
modal.htm
<script>
var obj = window.dialogArguments
alert("您传递的参数为:" + obj.name)
</script>
-------------------------------
2.可以通过window.returnValue向打开对话框的窗口返回信息,当然也可以是对象。例如:
------------------------------
parent.htm
<script>
str =window.showModalDialog("modal.htm",,"dialogWidth=200px;dialogHeight=100px");
alert(str);
</script>
modal.htm
<script>
window.returnValue="http://homepage.yesky.com";
</script>
------解决方案--------------------------------------------------------
点击结贴按钮 然后散分 楼主多给我点 我想升级 哈哈
探讨
怎么给分?
引用:

分分分,我要涨星星
引用:

正解! 谢谢解答!引用:

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.D……
  相关解决方案