HTML中执行.cs代码

    在近期的一个项目中,遇到了一个问题:

    要在客户端打开一个页面,但这个页面需要传递一个参数,如何将这个参数在客户端传递给页面,令我大费脑筋,终于在高手的指点下,终于解决了这个问题:如下:

 

<form id="FormMain" runat="server">
<script language="javascript" type="text/javascript">
function OnButtonBatchRequireDocumentClick()
{
window.open ('DocumentBatchRequire.aspx?ProjectID=<%= Request["ProjectID"] %>',
                      'newwindow', 'height=320, width=200, top=100, left=100, toolbar=no, menubar=no, 
scrollbars=yes,resizable=no,location=no, status=no'
); } </script> </form>
在这里用到了<%= %>其作用就是执行一段cs代码,并将结果返回到原地。这样,就可以在客户端取得“ProjectID”的参数了。

.csharpcode, .csharpcode pre { font-size: small; color: rgba(0, 0, 0, 1); font-family: consolas, “Courier New”, courier, monospace; background-color: rgba(255, 255, 255, 1) }
.csharpcode pre { margin: 0 }
.csharpcode .rem { color: rgba(0, 128, 0, 1) }
.csharpcode .kwrd { color: rgba(0, 0, 255, 1) }
.csharpcode .str { color: rgba(0, 96, 128, 1) }
.csharpcode .op { color: rgba(0, 0, 192, 1) }
.csharpcode .preproc { color: rgba(204, 102, 51, 1) }
.csharpcode .asp { background-color: rgba(255, 255, 0, 1) }
.csharpcode .html { color: rgba(128, 0, 0, 1) }
.csharpcode .attr { color: rgba(255, 0, 0, 1) }
.csharpcode .alt { background-color: rgba(244, 244, 244, 1); width: 100%; margin: 0 }
.csharpcode .lnum { color: rgba(96, 96, 96, 1) }原文链接:https://www.cnblogs.com/jiahaipeng/archive/2008/05/09/1190601.html
本文来源 爱码网,其版权均为 原网址 所有 与本站无关,文章内容系作者个人观点,不代表 本站 对观点赞同或支持。如需转载,请注明文章来源。

© 版权声明

相关文章