0

嗨,我想在我的页面中动态播放一部电影,但我的播放器需要一个 URL,并且它只从 Html 部分填充。如何将 URL 表单页面加载传递给 Html 部分。这是我的代码:谢谢

页面加载代码:

   protected void Page_Load(object sender, EventArgs e)
    {
       // string n = String.Format("{0}", Request.Form['customerName']);
        string connStr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        SqlConnection sqlconn = new SqlConnection(connStr);
        SqlCommand sqlcmd = new SqlCommand();
        sqlcmd = new SqlCommand("SELECT Pic FROM AllMemberOfSite where UserName=@UserName", sqlconn);
        sqlcmd.Parameters.AddWithValue("@UserName", (string)Session["User"]);
        sqlconn.Open();
        Image4.ImageUrl = ((string)sqlcmd.ExecuteScalar()).ToString();




        sqlcmd = new SqlCommand("SELECT Video FROM AddVideo where ID=@ID", sqlconn);
        sqlcmd.Parameters.AddWithValue("@ID", Request.QueryString["ID"]);
        string URL = ((string)sqlcmd.ExecuteScalar()).ToString();

        Page.DataBind();
        sqlcmd = new SqlCommand("SELECT Title FROM AddVideo where ID=@ID", sqlconn);
        sqlcmd.Parameters.AddWithValue("@ID", Request.QueryString["ID"]);
        Label6.Text = ((string)sqlcmd.ExecuteScalar()).ToString();


        sqlconn.Close();

    }

这是html鳕鱼:

    <?
    $mobile=mobile_device_detect();
          if($mobile)
{
    ?>
     <div class="video-js-box" >
                                                                 <video   id="example_video_1" class="video-js" width="590" height="442" controls="controls" preload="auto" align="center">
      <source src="videos/Ostad Pirmoradi2.flv" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' />


    </video>
  </div>



  <?
}else
{?>
        <div name="flashcontent2" id="flashcontent2"></div>
        <script type="text/javascript" language="javascript">
            if (!FlashDetect.installed) {
                document.getElementById("flashcontent2").innerHTML = "<b>This content requires the Adobe Flash Player. If the player does not load here in a moment please install flash. <a href=http://www.adobe.com/go/getflash/>GET FLASH HERE</a></b>";
            } else {
                // Flash embed code starts 
                //delete the below sample


                var so1 = new SWFObject("YTPlayer.swf", "YTPlayer", "640" "320",                 "8", null, true);
                so1.addParam("allowFullScreen", "true");
                so1.addParam("allowSciptAccess", "always");
                so1.addVariable("movieName", "videos/Ostad Pirmoradi2.flv");
                so1.addVariable("autoStart", "true");
                //so1.addVariable("logoPath", "logo/30alogo.png"); // 60*60 dimension
               // so1.addVariable("logoPosition", "top_left"); // accepted values                are top_left, top_right, bottom_left and bottom_right
             //   so1.addVariable("logoClickURL",     "http://www.flvhosting.com              
                      /af/idevaffiliate.php?id=385");
            //    so1.write("flashcontent2");
                // Flash Embed code ends
            }
        </script>
    <?}?>
4

3 回答 3

0

采用<asp:literal id="myMovie"></asp:literal>

比来自 c# 的填充myMovie.Text


此外:

using(SqlConnection sqlconn = new SqlConnection(connStr))
{
  // the rest of you code
}

这更好,因为在出​​现异常时,您不会让连接打开的时间超过所需时间。

于 2012-10-29T06:35:45.700 回答
0

制作 Sourcerunat="server"
并从后面的代码中获取该源 id 并给出

id.src = "your src from database".

就是这样。

于 2012-10-29T06:38:49.247 回答
0

试试这个

添加这样的方法

public string GetURL()
{
 string connStr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
 SqlConnection sqlconn = new SqlConnection(connStr);
 SqlCommand sqlcmd = new SqlCommand();
 sqlconn.Open();
 sqlcmd = new SqlCommand("SELECT Video FROM AddVideo where ID=@ID", sqlconn);
 sqlcmd.Parameters.AddWithValue("@ID", Request.QueryString["ID"]);
 string URL = ((string)sqlcmd.ExecuteScalar()).ToString();
 return URL;
}

并通过这样调用它在前端获得它的价值

假设如果你想在 img 中设置这个 URL 然后写这个

<img runat="server" id="image1" src='<%= GetURL() %>' alt="image one" />
于 2012-10-29T06:42:52.623 回答