原HyperLinkField代码 <asp:HyperLinkField DataNavigateUrlFields="TaskID" DataNavigateUrlFormatString="javascript:window.open ('AddTask.aspx', 'newwindow', 'height=300, width=400,top=200, left=200 ,toolbar=no, menubar=no, scrollbars=no')" DataTextField="TaskSummary" />
10 个解决方案
#1
function openwindow(url,name,iWidth,iHeight)
{
var url; //转向网页的地址;
var name; //网页名称,可为空;
var iWidth; //弹出窗口的宽度;
var iHeight; //弹出窗口的高度;
var iTop = (window.screen.availHeight-30-iHeight)/2; //获得窗口的垂直位置;
var iLeft = (window.screen.availWidth-10-iWidth)/2; //获得窗口的水平位置;
window.open(url,name,'height='+iHeight+',,innerHeight='+iHeight+',width='+iWidth+',innerWidth='+iWidth+',top='+iTop+',left='+iLeft+',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');
}
使用时调用这个函数即可。如:
<a href="javascript:void(0);" onclick="javascript:openwindow('a.html','',400,200);">转到a</a>
缺点:与原窗口的大小,位置无关,asp.net中Request.UrlRefferer.ToString()无法获取地址。
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
关闭子窗口并刷新父页面
Response.Write("<script>alert('增加成功.');opener.location.href=opener.location.href;opener=null;window.close();</script>");
{
var url; //转向网页的地址;
var name; //网页名称,可为空;
var iWidth; //弹出窗口的宽度;
var iHeight; //弹出窗口的高度;
var iTop = (window.screen.availHeight-30-iHeight)/2; //获得窗口的垂直位置;
var iLeft = (window.screen.availWidth-10-iWidth)/2; //获得窗口的水平位置;
window.open(url,name,'height='+iHeight+',,innerHeight='+iHeight+',width='+iWidth+',innerWidth='+iWidth+',top='+iTop+',left='+iLeft+',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');
}
使用时调用这个函数即可。如:
<a href="javascript:void(0);" onclick="javascript:openwindow('a.html','',400,200);">转到a</a>
缺点:与原窗口的大小,位置无关,asp.net中Request.UrlRefferer.ToString()无法获取地址。
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
关闭子窗口并刷新父页面
Response.Write("<script>alert('增加成功.');opener.location.href=opener.location.href;opener=null;window.close();</script>");
#2
我要传个ID怎么传呢??这个ID是根据我当前点的行中绑定的ID传过去
#3
<asp:LinkButton ID="lbContent" runat="server" CommandArgument='<%# Eval("MessageID") %>' OnCommand="lbContent_Command" ><%# TruncateString(DataBinder.Eval(Container.DataItem, "SendContent"),60)%></asp:LinkButton>
protected void lbContent_Command(object sender, CommandEventArgs e)
{
string messageId = e.CommandArgument.ToString();
string sqlupdate = @"update t_message set fileid =1 where MessageID=" + messageId;
DBUtility.DbHelperSQL.ExecuteSql(sqlupdate);
string script="openwindows('MessageShow.aspx?id="+messageId+"');location.href='MessageReceived.aspx'";
Page.ClientScript.RegisterStartupScript(this.GetType(),"reload",script, true);
}
protected void lbContent_Command(object sender, CommandEventArgs e)
{
string messageId = e.CommandArgument.ToString();
string sqlupdate = @"update t_message set fileid =1 where MessageID=" + messageId;
DBUtility.DbHelperSQL.ExecuteSql(sqlupdate);
string script="openwindows('MessageShow.aspx?id="+messageId+"');location.href='MessageReceived.aspx'";
Page.ClientScript.RegisterStartupScript(this.GetType(),"reload",script, true);
}
#4
这样做放着LinkButton 的这个页面在点击打开窗口后是不是会刷新一下?
#5
加个 onclick事件 其他的js实现吧
#6
UP
#7
.............
#8
用别的方法解决了。。。。
<script type="text/javascript">
function show(taskid)
{
window.open ('AddTask.aspx?id='+taskid, 'newwindow', 'height=300, width=400,top=200, left=200 ,toolbar=no, menubar=no, scrollbars=no')
}
</script>
<ItemTemplate>
<a href="#" onclick='show(<%#DataBinder.Eval(Container.DataItem,"TaskID") %>);'><asp:label id="labelSumary" runat="server" Text='<% #Bind("TaskSummary")%>'></asp:label></a>
</ItemTemplate>
<script type="text/javascript">
function show(taskid)
{
window.open ('AddTask.aspx?id='+taskid, 'newwindow', 'height=300, width=400,top=200, left=200 ,toolbar=no, menubar=no, scrollbars=no')
}
</script>
<ItemTemplate>
<a href="#" onclick='show(<%#DataBinder.Eval(Container.DataItem,"TaskID") %>);'><asp:label id="labelSumary" runat="server" Text='<% #Bind("TaskSummary")%>'></asp:label></a>
</ItemTemplate>
#9
怎么解决的啊,我怎么还没弄好啊
#10
顶8楼的
#1
function openwindow(url,name,iWidth,iHeight)
{
var url; //转向网页的地址;
var name; //网页名称,可为空;
var iWidth; //弹出窗口的宽度;
var iHeight; //弹出窗口的高度;
var iTop = (window.screen.availHeight-30-iHeight)/2; //获得窗口的垂直位置;
var iLeft = (window.screen.availWidth-10-iWidth)/2; //获得窗口的水平位置;
window.open(url,name,'height='+iHeight+',,innerHeight='+iHeight+',width='+iWidth+',innerWidth='+iWidth+',top='+iTop+',left='+iLeft+',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');
}
使用时调用这个函数即可。如:
<a href="javascript:void(0);" onclick="javascript:openwindow('a.html','',400,200);">转到a</a>
缺点:与原窗口的大小,位置无关,asp.net中Request.UrlRefferer.ToString()无法获取地址。
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
关闭子窗口并刷新父页面
Response.Write("<script>alert('增加成功.');opener.location.href=opener.location.href;opener=null;window.close();</script>");
{
var url; //转向网页的地址;
var name; //网页名称,可为空;
var iWidth; //弹出窗口的宽度;
var iHeight; //弹出窗口的高度;
var iTop = (window.screen.availHeight-30-iHeight)/2; //获得窗口的垂直位置;
var iLeft = (window.screen.availWidth-10-iWidth)/2; //获得窗口的水平位置;
window.open(url,name,'height='+iHeight+',,innerHeight='+iHeight+',width='+iWidth+',innerWidth='+iWidth+',top='+iTop+',left='+iLeft+',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');
}
使用时调用这个函数即可。如:
<a href="javascript:void(0);" onclick="javascript:openwindow('a.html','',400,200);">转到a</a>
缺点:与原窗口的大小,位置无关,asp.net中Request.UrlRefferer.ToString()无法获取地址。
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
关闭子窗口并刷新父页面
Response.Write("<script>alert('增加成功.');opener.location.href=opener.location.href;opener=null;window.close();</script>");
#2
我要传个ID怎么传呢??这个ID是根据我当前点的行中绑定的ID传过去
#3
<asp:LinkButton ID="lbContent" runat="server" CommandArgument='<%# Eval("MessageID") %>' OnCommand="lbContent_Command" ><%# TruncateString(DataBinder.Eval(Container.DataItem, "SendContent"),60)%></asp:LinkButton>
protected void lbContent_Command(object sender, CommandEventArgs e)
{
string messageId = e.CommandArgument.ToString();
string sqlupdate = @"update t_message set fileid =1 where MessageID=" + messageId;
DBUtility.DbHelperSQL.ExecuteSql(sqlupdate);
string script="openwindows('MessageShow.aspx?id="+messageId+"');location.href='MessageReceived.aspx'";
Page.ClientScript.RegisterStartupScript(this.GetType(),"reload",script, true);
}
protected void lbContent_Command(object sender, CommandEventArgs e)
{
string messageId = e.CommandArgument.ToString();
string sqlupdate = @"update t_message set fileid =1 where MessageID=" + messageId;
DBUtility.DbHelperSQL.ExecuteSql(sqlupdate);
string script="openwindows('MessageShow.aspx?id="+messageId+"');location.href='MessageReceived.aspx'";
Page.ClientScript.RegisterStartupScript(this.GetType(),"reload",script, true);
}
#4
这样做放着LinkButton 的这个页面在点击打开窗口后是不是会刷新一下?
#5
加个 onclick事件 其他的js实现吧
#6
UP
#7
.............
#8
用别的方法解决了。。。。
<script type="text/javascript">
function show(taskid)
{
window.open ('AddTask.aspx?id='+taskid, 'newwindow', 'height=300, width=400,top=200, left=200 ,toolbar=no, menubar=no, scrollbars=no')
}
</script>
<ItemTemplate>
<a href="#" onclick='show(<%#DataBinder.Eval(Container.DataItem,"TaskID") %>);'><asp:label id="labelSumary" runat="server" Text='<% #Bind("TaskSummary")%>'></asp:label></a>
</ItemTemplate>
<script type="text/javascript">
function show(taskid)
{
window.open ('AddTask.aspx?id='+taskid, 'newwindow', 'height=300, width=400,top=200, left=200 ,toolbar=no, menubar=no, scrollbars=no')
}
</script>
<ItemTemplate>
<a href="#" onclick='show(<%#DataBinder.Eval(Container.DataItem,"TaskID") %>);'><asp:label id="labelSumary" runat="server" Text='<% #Bind("TaskSummary")%>'></asp:label></a>
</ItemTemplate>
#9
怎么解决的啊,我怎么还没弄好啊
#10
顶8楼的