简体   繁体   English

如何以 web 形式从 asp.net 控件到 javascript 获取值

[英]How to get values from an asp.net control to a javascript in the web form

Good day.再会。 I have a dropdown list control called audioList.我有一个名为 audioList 的下拉列表控件。 Whenever the page loads audioList is populated from a database.每当页面加载时,audioList 都会从数据库中填充。 On the web form I have JPlayer which is a JQuery audio player.在 web 表格上,我有 JPlayer,它是一个 JQuery 音频播放器。 What I want to do is to load JPlayer with the value taken from audioList.我想要做的是使用从 audioList 中获取的值加载 JPlayer。

Here is the code for JPlayer on the web form:这是 web 表单上 JPlayer 的代码:

<script type="text/javascript">
  $(document).ready(function () {
      $("#jquery_jplayer_1").jPlayer({
          ready: function () {
              $(this).jPlayer("setMedia", {
                  mp3: "" //<--This part links to the mp3's location
              });
          },
          swfPath: "/MediaPlayer/jQuery.jPlayer.2.0.0/",
          supplied: "mp3"
      });
  });
</script>

Here is the code where audioList is:这是 audioList 所在的代码:

protected void Page_Load(object sender, EventArgs e)
    {

        string query = "SELECT Media_Directory FROM media";

        DataTable dt = MySQLHandler.pull(query);
        audioList.DataSource = dt;
        audioList.DataTextField = dt.Columns[0].ToString();
        audioList.DataValueField = dt.Columns[0].ToString(); //<--mp3 file location which is to be placed in JPlayer
        audioList.DataBind();

    }

You can call your jplayer function to play the mp3 onChange event of the drop down您可以调用您的 jplayer function 播放下拉的 mp3 onChange 事件

see Fire event each time a DropDownList item is selected with jQuery 每次使用 jQuery 选择 DropDownList 项目时,请参阅 Fire 事件

basically on the drop down selected add a jquery event that will set a property on the jplayer基本上在下拉选择中添加一个 jquery 事件,它将在 jplayer 上设置一个属性

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 ASP.NET 中将值从 Web 表单传递给另一个? - How pass a values from a web form to another in ASP.NET? 如何从C#ASP.NET Web表单背后的代码获取图表值 - How to get values of chart from code behind c# asp.net web form 如何从 asp.net web 表单中的 gridview 获取值? - how to get values from gridview in asp.net web forms? 如何将值从窗体窗体应用发送到asp.net服务器并从中获取值窗体数据库? - how to send values form the window form appliction to an asp.net server and get the values form database from there? 在 javascript 中引用 ASP.NET web 控件 - Referencing the ASP.NET web control in javascript 如何在JavaScript中使用具有相同ID的两个文本框获取asp.net用户控件的值 - How to get the values of an asp.net user control with two textboxes with same id in javascript Asp.Net从PlaceHolder获取控制值 - Asp.Net Get Control Values from PlaceHolder 如何在ASP.NET Web表单中使用Ajax更新ListView中的值 - How to update values in a ListView with ajax in asp.net web form 如何从ASP.NET网站(而不是Web应用程序)中的用户控件获取父页面 - How can I get the parent page from a User Control in an ASP.NET Website (not Web Application) ASP.NET:如何从GridView控件的选定行中获取值 - ASP.NET: How to get values from a selected row from GridView control
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM