美好的一天。我有一個名爲audioList的下拉列表控件。每當頁面加載時,audioList都會從數據庫中填充。在Web窗體上,我有JPlayer,它是一個JQuery音頻播放器。我想要做的是用從audioList中獲取的值加載JPlayer。如何從一個asp.net控件獲取值到網頁表單中的javascript
這裏是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();
}