现在有xx.aspx.cs
    protected void Page_Load(object sender, EventArgs e)
    {        if (IsPostBack)
        {
            if (Request.QueryString["mode"] != null)
            {
                string User = Request.QueryString["mode"].ToString();
            }
        }
        else
        {
            Outputjs();
        }
    }
    private override void Outputjs(HtmlTextWriter output)
    {
   output.Write("<script  type=\"text/javascript\">flowplayer(\"player\", \"./flowplayer-3.2.7.swf\"); </script>");
        output.Write("<a id=\"flash_index\" href=\"http://localhost:4476/SampleWebsite/Fox_index.flv\" style=\"display:block;width:886px;height:659px\" id=\"player\"></a> ");
    }   想在页面Page_Load的时候判断是否是回传   如果不是的话  就调用下面的函数  输出页面Html代码

解决方案 »

  1.   

    StringBuilder strJS = new StringBuilder();
    strJS.Append("<script  type=\"text/javascript\">flowplayer(\"player\", \"./flowplayer-3.2.7.swf\"); </script>");
    strJS.Append("<a id=\"flash_index\" href=\"/SampleWebsite/Fox_index.flv\" style=\"display:block;width:886px;height:659px\" id=\"player\"></a>");
    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), strJS.GetHashCode().ToString(), strJS, true);
    试试
      

  2.   

    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), strJS.GetHashCode().ToString(), strJS, true);
     的第三个参数要不要加上.tostring()
      

  3.   


    <form id="form1" runat="server">
        <div>
            <asp:Button ID="btnPostBack" runat="server" Text="PostBack" />
            <a href="/SampleWebsite/Fox_index.flv" style="display:none;width:886px;height:659px;" id="player"></a>
        </div>
        <input type="hidden" id="hidPB" runat="server" value="0" />
        </form>
        <script type="text/javascript">
            function flowplayer(param1,param2){
                
            }
            var pb = document.getElementById("<%= hidPB.ClientID %>").value;
            if(pb=="0"){ //0表示非回发状态
                document.getElementById("player").style.display="block";
                flowplayer("player", "./flowplayer-3.2.7.swf");
            }
        </script>
    protected void Page_Load(object sender, EventArgs e)
            {
                if(IsPostBack)
                    hidPB.Value = "1";
            }
      

  4.   

    报错:Microsoft JScript 运行时错误: 无法获取属性“style”的值: 对象为 null 或未定义
    怎么解决?
      

  5.   

    你直接给前台放一个Lable,然后在后台给那个Lable赋你要输出的HTML标签就可以了。