[英]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.