Thursday, June 30, 2011

How to implement embedded media player in asp.net c#

Java Script Alert - Run with asp.net update panel

string alertScript = "javascript: alert('Error Occured, Please try again later')";
ScriptManager.RegisterStartupScript(this, this.GetType(), "alertScript",
alertScript, true);

Friday, June 24, 2011

Export to word from gridview in c#

protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{

Response.ClearContent();
Response.Buffer = true;
Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "Individual report of user" + " " + ddlagent.SelectedItem.Text + ".doc"));
Response.ContentType = "application/ms-word";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
getgrid();
//Change the Header Row back to white color
//Applying stlye to gridview header cells
DataList1.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();


}

Export to Excel from gridview in c#

protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
Response.ClearContent();
Response.Buffer = true;
if (chkall.Checked == true)
{
Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "calls report of alluser"+txtfromdate.Text+" "+"to"+" "+txttodate.Text+".xls"));
}
else
{
Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "calls report of user" + " " + ddlagent.SelectedItem.Text + ".xls"));
}
Response.ContentType = "application/ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
reportgrid.AllowPaging = false;
getgrid();
//Change the Header Row back to white color
reportgrid.HeaderRow.Style.Add("background-color", "#afabc4");
//Applying stlye to gridview header cells
for (int i = 0; i < reportgrid.HeaderRow.Cells.Count; i++)
{
reportgrid.HeaderRow.Cells[i].Style.Add("background-color", "#afabc4");
}
int j = 1;
//This loop is used to apply stlye to cells based on particular row
foreach (GridViewRow gvrow in reportgrid.Rows)
{
gvrow.BackColor = Color.White;
if (j <= reportgrid.Rows.Count)
{
//if (j % 2 != 0)
//{
for (int k = 0; k < gvrow.Cells.Count; k++)
{
gvrow.Cells[k].Style.Add("background-color", "#FFFFFF");
}
//}
}
j++;
}

reportgrid.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();



}

Sunday, June 19, 2011

How to Remove Rendering Function error from asp.net c# program???

Disable the event validations in asp.net page using below:

<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" EnableEventValidation="false" CodeBehind="Reports.aspx.cs" Inherits="Reports" %>

And Override the Rendering Verification function in c#:


public override void VerifyRenderingInServerForm(Control control)
{

}

Thursday, June 16, 2011

how to execute audio converters using System.Diagnostics in c#(GoldWave)

System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo stratInfo = new System.Diagnostics.ProcessStartInfo();
stratInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
stratInfo.FileName = "C:\\Program Files\\GoldWave\\Goldwave.exe";
//stratInfo.Arguments = "/C copy /b image1.jpg + Archive.rar image2.jpg";
stratInfo.Arguments = "/process:MP3 C:\Users\jaganath\Desktop\bosco.VC2";

process.StartInfo = stratInfo;
process.Start();