美好的一天。我有一个名为audioList 的下拉列表控件。每当页面加载时,audioList 就会从数据库中填充。在网络表单上,我有 JPlayer,它是一个 JQuery 音频播放器。我想要做的是使用从audioList 获取的值加载JPlayer。
以下是 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>
这是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();
}
最佳答案
您可以调用jplayer函数来播放下拉菜单的mp3 onChange事件
关于c# - 如何将值从 ASP.NET 控件获取到 Web 表单中的 javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6596163/