asp.net - 在 ASP.NET 站点上添加事件

标签 asp.net css html

我正在尝试在 ASP.net 网站上创建一个按钮,当您按下该按钮时,音乐播放器将开始在该网站上播放流媒体音乐。

我知道如何创建按钮以及如何处理事件,但我无法让我的播放器开始播放 *.mp3 文件。

这是我在常规 html 网站上使用的音乐播放器。

 <embed src="music/ToGlory.mp3" width="140" height="40" autostart="false" loop="TRUE" hidden="True"></embed>

我试图做的事情看起来像这样:

Sub submit(s As Object, e As EventArgs)

button=embed src="music/ToGlory.mp3" width="140" height="40" autostart="false" loop="TRUE" hidden="True" /embed

End Sub

最佳答案

尝试

.aspx Button 控件

<asp:button id="Button1"
       usesubmitbehavior="true"
       text="Click it and Play it!"
       onclientclick="Play('URL to sound file, ex: http://www.my.com/a.mp3')"
       runat="server" onclick="Button1_Click" />

JavaScript:

<script language="javascript" type="text/javascript">
 function Play(soundfile) {
 document.getElementById("Button1").innerHTML=
 "<embed src=\""+soundfile+"\" hidden=\"true\" autostart=\"true\" loop=\"false\" />";
 }
 </script>

如果有帮助,+1 :)。

关于asp.net - 在 ASP.NET 站点上添加事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9107727/

相关文章:

asp.net - 在 ASP.NET 成员提供者数据库中加密密码

asp.net - 谷歌向网站链接添加奇怪的目录名称

html - 显示重影值的子菜单

html - 如何限制 div 内的文本和元素

javascript - 如何在按钮单击事件上加载标记

asp.net - ASP :Button having position:fixed/absolute is not clickable on firefox nor google chrome

asp.net - 阻止 app_offline.htm 在每次构建时创建和删除?

javascript - 显示来自 HTML 文档的多个 SVG 图层

php - 我在电子邮件中的结果只显示 "resource id#7"

jquery - 社交媒体图标在悬停时会更改为相应的颜色