Click here to Skip to main content
15,888,325 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more: , +
My problem is im unable to get the audio player in gridview can anyone plz help me for this


<asp:GridView ID="GridView1" DataKeyNames="ID" OnRowDeleting="GridView1_RowDeleting" runat="server" AutoGenerateColumns="False">
<columns>
<asp:TemplateField HeaderText=" ID ">
<edititemtemplate>
<asp:TextBox ID="txtID" runat="server" Text='<%# Bind("ID") %>'>

<itemtemplate>
<asp:Label ID="lblID" runat="server" Text='<%# Bind("ID") %>'>


<asp:TemplateField HeaderText=" Message ID ">
<edititemtemplate>
<asp:TextBox ID="txtMessageID" runat="server" Text='<%# Bind("MessageID") %>'>

<itemtemplate>
<asp:Label ID="lblMessageID" runat="server" Text='<%# Bind("MessageID") %>'>


<asp:TemplateField HeaderText=" Message Name ">
<edititemtemplate>
<asp:TextBox ID="txtMessageName" runat="server" Text='<%# Bind("MessageName") %>'>

<itemtemplate>
<asp:Label ID="lblMessageName" runat="server" Text='<%# Bind("MessageName") %>'>



<%--<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="200px" />--%>

<%--<audio controls="controls">
<source src='../PassengerInformation/English/<%# Eval("EnglishMessage") %>' type="audio/mpeg">
<%--<source src="../PassengerInformation/English/Heeriye%20-%20320Kbps%20-%20DJMaza.Fun%20(mp3cut.net).mp3" type="audio/ogg">
Your browser does not support this audio format.
--%>
<asp:TemplateField HeaderText="English Message">
<itemtemplate>
<object type="application/x-shockwave-flash" data='dewplayer-vol.swf?mp3=Announcement.ashx?Id=<%# Eval("ID") %>' width="240" height="20" id="dewplayer">
<param name="wmode" value="transparent" />
<param name="movie" value='dewplayer-vol.swf?mp3=Announcement.ashx?ID=<%# Eval("ID") %>' />



<%--<asp:TemplateField HeaderText=" English Message ">
<edititemtemplate>
<asp:TextBox ID="txtEnglishMessage" runat="server" Text='<%# Bind("EnglishMessage") %>'>

<itemtemplate>
<asp:Label ID="lblEnglishMessage" runat="server" Text='<%# Bind("EnglishMessage") %>'>

--%>
<asp:TemplateField HeaderText="Regional Message">
<itemtemplate>
<object type="application/x-shockwave-flash" data='dewplayer-vol.swf?mp3=Announcement.ashx?Id=<%# Eval("ID") %>' width="240" height="20" id="dewplayer">
<param name="wmode" value="transparent" />
<param name="movie" value='dewplayer-vol.swf?mp3=Announcement.ashx?Id=<%# Eval("ID") %>' />



<%-- <asp:TemplateField HeaderText=" Regional Message ">
<edititemtemplate>
<asp:TextBox ID="txtRegionalMessage" runat="server" Text='<%# Bind("RegionalMessage") %>'>

<itemtemplate>
<asp:Label ID="lblRegionalMessage" runat="server" Text='<%# Bind("RegionalMessage") %>'>

--%>
<asp:TemplateField HeaderText="Hindi Message">
<itemtemplate>
<object type="application/x-shockwave-flash" data='dewplayer-vol.swf?mp3=Announcement.ashx?Id=<%# Eval("ID") %>' width="240" height="20" id="dewplayer">
<param name="wmode" value="transparent" />
<param name="movie" value='dewplayer-vol.swf?mp3=Announcement.ashx?Id=<%# Eval("ID") %>' />



<%--<asp:TemplateField HeaderText=" Hindi Message ">
<edititemtemplate>
<asp:TextBox ID="txtHindiMessage" runat="server" Text='<%# Bind("HindiMessage") %>'>

<itemtemplate>
<asp:Label ID="lblHindiMessage" runat="server" Text='<%# Bind("HindiMessage") %>'>

--%>
<asp:CommandField ShowDeleteButton="True" />

<%-- <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#FFF1D4" />
<SortedAscendingHeaderStyle BackColor="#B95C30" />
<SortedDescendingCellStyle BackColor="#F1E5CE" />
<SortedDescendingHeaderStyle BackColor="#93451F" />--%>

above is html code and belo is cs code

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
LoadData();
}
}

private void LoadData()
{
String CS = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
using (SqlConnection con = new SqlConnection(CS))
{
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "Select ID, MessageID, MessageName, EnglishMessage, RegionalMessage, HindiMessage from SpecialAnnouncement order by ID desc";
cmd.Connection = con;
con.Open();
GridView1.DataSource = cmd.ExecuteReader();
GridView1.DataBind();
con.Close();
}
}






}

What I have tried:

<%@ WebHandler Language="C#" Class="Announcement" %>

using System;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

public class Announcement : IHttpHandler
{

public void ProcessRequest(HttpContext context)
{
int id = int.Parse(context.Request.QueryString["id"]);
byte[] bytes;
byte[] bytes2;
byte[] bytes3;
string MessageID;
string MessageName;
string CS = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
using (SqlConnection con = new SqlConnection(CS))
{
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "Select MessageID, MessageName, EnglishMessage, RegionalMessage, HindiMessage from SpecialAnnouncement where ID=@ID";
cmd.Parameters.AddWithValue("@ID", id);
cmd.Connection = con;
con.Open();
SqlDataReader sdr = cmd.ExecuteReader();
sdr.Read();
bytes = (byte[])sdr["EnglishMessage"];
bytes2 = (byte[])sdr["RegionalMessage"];
bytes3 = (byte[])sdr["HindiMessage"];
MessageID = sdr["MessageID"].ToString();
MessageName = sdr["MessageName"].ToString();
con.Close();
}
}
context.Response.Clear();
context.Response.Buffer = true;
context.Response.AppendHeader("Content-Disposition", "attachment; filename=" + MessageID);
context.Response.ContentType = MessageName;
context.Response.BinaryWrite(bytes);
context.Response.End();
}

public bool IsReusable
{
get
{
return false;
}
}

}

this is my ashx file
Posted
Updated 31-Jul-18 3:00am
v3
Comments
F-ES Sitecore 31-Jul-18 8:07am    
Do some debugging...is the html being rendered ok? Is the flash\whatever component loading ok? Is it that the audio just isn't playing? Are your back-end methods being called? Do the calls look ok on the network tab of the browser tools? We don't have your data, and we don't have access to your machine so dumping 1,000 lines of code isn't enough to allow anyone to help you as there are so many steps here and we don't know which one is at fault.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900