62,046
社区成员
发帖
与我相关
我的任务
分享
<script language="javascript" type="text/javascript">
function ManageSoundControl(action)
{
var soundControl = document.getElementById("soundControl");
if(action == "play")
{
soundControl.play();
}
if(action == "stop")
{
soundControl.stop();
}
}
</script>
<embed id="soundControl" src="upfiles/263508.mp3" loop=false autostart=false width=10 height=10></embed>
<input id="btPlay" type="button" value="播放" onclick="ManageSoundControl('play')" />
<input id="btStop" type="button" value="停止" onclick="ManageSoundControl('stop')" />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None" >
<Columns>
<asp:TemplateField HeaderText="图标">
<ItemTemplate>
<embed id="soundControl" src="upfiles/<%#DataBinder.Eval(Container.DataItem,"soundName")%>" loop=false autostart=false width=10 height=10></embed>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="播放" >
<ItemStyle Wrap="False" Width="150px" />
<ItemTemplate>
<input id="btPlay" type="button" value="播放" onclick="ManageSoundControl('play')" />
<input id="btStop" type="button" value="停止" onclick="ManageSoundControl('stop')" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="录音文件">
<ItemStyle Wrap="False" Width="150px" />
<ItemTemplate>
<asp:Label ID="lblname" Width="150px" runat="server" Text='<%# Bind("soundName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
public string soundName = "";
protected void Page_Load(object sender, EventArgs e)
{
DbCommand db_src = db.GetSqlStringCommand("select soundName,tid from test");
db.ExecuteNonQuery(db_src);
GridView1.DataSource = db.ExecuteDataSet(db_src).Tables[0];
GridView1.DataBind();
}
return tr.getElemenetsByTagName('embed')[0];
//===>
return tr.getElementsByTagName('embed')[0];
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None" >
<Columns>
<asp:TemplateField HeaderText="图标">
<ItemTemplate>
<embed id="soundControl" src="upfiles/<%#DataBinder.Eval(Container.DataItem,"soundName")%>" loop=false autostart=false width=10 height=10></embed>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="播放" >
<ItemStyle Wrap="False" Width="150px" />
<ItemTemplate><!---注意这里---->
<input id="btPlay" type="button" value="播放" onclick="ManageSoundControl('play',this)" />
<input id="btStop" type="button" value="停止" onclick="ManageSoundControl('stop',this)" /><!---注意这里---->
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="录音文件">
<ItemStyle Wrap="False" Width="150px" />
<ItemTemplate>
<asp:Label ID="lblname" Width="150px" runat="server" Text='<%# Bind("soundName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<script language="javascript" type="text/javascript">
function FindEmbed(btn) {
var tr, rst;
while (tr = btn.parentNode) { if (tr.tagName == 'TR') break; }
return tr.getElemenetsByTagName('embed')[0];
}
function ManageSoundControl(action, btn) {
var soundControl = FindEmbed(btn);
if (action == "play") { soundControl.play(); }
if (action == "stop") { soundControl.stop(); }
}
</script>