向JScript里面声明的var img赋值
从后台赋值...
高手来解答下吧...在线等你

解决方案 »

  1.   

    <script type="text/javascript">
       var img = <%= Img %>
    </script>========
    .aspx.cs
    定义一个公共的字段或者属性
    public string Img = "Hello Js";
      

  2.   

    Response.Write("<script>赋值</script>")
      

  3.   

    在后台用Page.RegisterClientScriptBlock方法注册脚本,参考下面的代码:// Page_Loadstring strScript = "var img='value';ClientScript.RegisterClientScriptBlock(
    typeof(Page),
    "script-key",
    strScript,
    true
    );
      

  4.   

    后台调用前台方法,然后赋值
    ScriptManager.RegisterStartupScript(this, this.GetType(), "", "SetText('"+ bianliang + "')", true);function SetText(image)
            {
                var img;
                img = image;
            }
      

  5.   

    最快的方法,Response.Write("<script type='text/javascript'>var msg='"+变量+"'</script>")
      

  6.   

    直接通过<%%>输出你想要赋值的

    <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 
    );
      

  7.   

                        var focus_width=305
     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...要怎么改
      

  8.   

    var img = '<%=后台变量%>'
      

  9.   


     Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>img='value';</script>");
      

  10.   

    var pics= '<%=img %>';
      

  11.   

    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赋值就可以了
        }}解决了就说一声
      

  12.   

    var img = "<%= 后台变量%>";
      

  13.   

    <script type="text/javascript"> 
      var img = <%= Img %> 
    </script> ======== 
    .aspx.cs 
    定义一个公共的字段或者属性 
    public string Img = "Hello Js"; 
      

  14.   

    <%= Img %> 
      

  15.   

    后台定义public或protected的变量
    var img = " <%= 变量%>";
      

  16.   

    学习一下,正好学习ASP.net