aspx页面写:<% Response.Write(value);%>.CS页面写 public partial class index : System.Web.UI.Page { public string value; protected void Page_Load(object sender, EventArgs e) {//在这里给value赋值就可以了 }}解决了就说一声
var img = "<%= 后台变量%>";
<script type="text/javascript"> var img = <%= Img %> </script> ======== .aspx.cs 定义一个公共的字段或者属性 public string Img = "Hello Js";
var img = <%= Img %>
</script>========
.aspx.cs
定义一个公共的字段或者属性
public string Img = "Hello Js";
typeof(Page),
"script-key",
strScript,
true
);
ScriptManager.RegisterStartupScript(this, this.GetType(), "", "SetText('"+ bianliang + "')", true);function SetText(image)
{
var img;
img = image;
}
如
<script type="text/javascript">
var img = <%= Img %>
</script> ========
.aspx.cs
定义一个公共的字段或者属性
public string Img = "Hello Js";当然也可以输出JS代码Response.Write(" <script>赋值 </script>")也可以
// Page_Load string strScript = "var img='value'; ClientScript.RegisterClientScriptBlock(
typeof(Page),
"script-key",
strScript,
true
);
var focus_height=446
var text_height=18
var swf_height = focus_height+text_height
var pics=<%=img %>'|'
var links='1|2|3|4'
var texts='1|2|3|4'
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ focus_width +'" height="'+ swf_height +'">');
document.write('<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="http://sports.qq.com/flash/playswf.swf"><param name=wmode value=transparent><param name="quality" value="high">');
document.write('<param name="menu" value="false"><param name=wmode value="opaque">');
document.write('<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">');
document.write('<embed src="http://sports.qq.com/flash/playswf.swf" wmode="opaque" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'" menu="false" bgcolor="#DADADA" quality="high" width="'+ focus_width +'" height="'+ swf_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'); document.write('</object>');
这是那个JS...要怎么改
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>img='value';</script>");
public partial class index : System.Web.UI.Page
{
public string value;
protected void Page_Load(object sender, EventArgs e)
{//在这里给value赋值就可以了
}}解决了就说一声
var img = <%= Img %>
</script> ========
.aspx.cs
定义一个公共的字段或者属性
public string Img = "Hello Js";
var img = " <%= 变量%>";