【问题标题】:Adding an Event on ASP.NET sites在 ASP.NET 站点上添加事件
【发布时间】:2012-02-02 05:46:49
【问题描述】:

我正在尝试在 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

结束子

【问题讨论】:

  • 好吧,在这一点上没关系,因为服务器正在崩溃,错误日志并没有真正说明太多
  • 日志系统是您应该添加到网站的第一件事。查看系统的事件查看器 - 应用程序或系统日志中是否有任何内容。
  • 确实如此,因为我是 ASP.NET 的新手,而且我正在自学,所以我将不得不对此进行更多研究

标签: asp.net css html


【解决方案1】:

试试

.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 如果这有帮助:) .

【讨论】:

  • 我会尝试并告诉你。感谢您的努力。
  • 能否指导我了解一下按钮的
  • 我一定会的。让我插上电源看看会发生什么
  • 请注意,在getElementById 函数中,您必须传递标记中定义的Button id。
  • BC30456是什么意思:'Button1_Click'不是'ASP.startmusic_aspx'的成员。
猜你喜欢
  • 1970-01-01
  • 2012-04-15
  • 2017-08-21
  • 1970-01-01
  • 2019-04-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多