Archive for the ‘Html’ Category

Exporting grid data to PDF using asp.net

Introduction:
Here I will explain how to export gridview data to PDF using asp.net.

Description:

In my previous articles I explained clearly “Exporting grid data to Excel and word”. Now I will explain how to export gridview data to PDF using asp.net. In asp.net we don’t have direct feature to export gridview data to PDF for that reason here I am using third party library ITextSharp reference. The dll is available here ITextSharp first download dll from this site after that create one new website in visual studio and add ITextsharp dll reference to newly created website after that design aspx page like this

 <html xmlns=”http://www.w3.org/1999/xhtml”&gt;

<head id=”Head1″ runat=”server”>

<title></title>

</head>

<body>

<form id=”form1″ runat=”server”>

<div>

<table>

<tr>

<td align=”right”>

<asp:ImageButton ID=”btnPDF” runat=”server” ImageUrl=”~/PDF.jpg” Width=”32px”

Height=”32px” onclick=”btnPDF_Click”/>

</td>

</tr>

<tr>

<td>

<asp:GridView runat=”server” ID=”gvdetails” DataSourceID=”dsdetails”  

AllowPaging=”true” AllowSorting=”true” AutoGenerateColumns=”false”>

<RowStyle BackColor=”#EFF3FB” />

<FooterStyle BackColor=”#507CD1″ Font-Bold=”True” ForeColor=”White” />

<PagerStyle BackColor=”#2461BF” ForeColor=”White” HorizontalAlign=”Center” />

<HeaderStyle BackColor=”#507CD1″ Font-Bold=”True” ForeColor=”White” />

<AlternatingRowStyle BackColor=”White” />

<Columns>

<asp:BoundField DataField=”UserId” HeaderText=”UserId” />

<asp:BoundField DataField=”UserName” HeaderText=”UserName” />

<asp:BoundField DataField=”LastName” HeaderText=”LastName” />

<asp:BoundField DataField=”Location” HeaderText=”Location” />

</Columns>

</asp:GridView>

</td>

</tr>

</table>

<asp:SqlDataSource ID=”dsdetails” runat=”server”ConnectionString=”<%$ConnectionStrings:dbconnection %>

SelectCommand=”select * from UserInformation”/>

</div>

</form>

</body>

</html>

Here don’t forgot to set the connection string in web.config file here I am getting database connection from web.config file for that reason you need to set the connectionstring in web.config file like this 

<connectionStrings>

<add name=dbconnection connectionString=Data Source=SD;Integrated Security=true;Initial Catalog=MySampleDB/>

</connectionStrings>

After set the connection string in web.config file now we are able to get the data from database and we can bind that data to gridview by using sqldatasource. Now if you run application gridview appears like this

Now in code behind add these references

using iTextSharp.text;

using iTextSharp.text.pdf;

using iTextSharp.text.html.simpleparser;

After that write the following code in code behind


public override void VerifyRenderingInServerForm(Control control)

{

/* Verifies that the control is rendered */

}

protected void btnPDF_Click(object sender, ImageClickEventArgs e)

{

Response.ContentType = “application/pdf”;

Response.AddHeader(“content-disposition”“attachment;filename=UserDetails.pdf”);

Response.Cache.SetCacheability(HttpCacheability.NoCache);

StringWriter sw = new StringWriter();

HtmlTextWriter hw = new HtmlTextWriter(sw);

gvdetails.AllowPaging = false;

gvdetails.DataBind();

gvdetails.RenderControl(hw);

gvdetails.HeaderRow.Style.Add(“width”“15%”);

gvdetails.HeaderRow.Style.Add(“font-size”“10px”);

gvdetails.Style.Add(“text-decoration”“none”);

gvdetails.Style.Add(“font-family”“Arial, Helvetica, sans-serif;”);

gvdetails.Style.Add(“font-size”“8px”);

StringReader sr = new StringReader(sw.ToString());

Document pdfDoc = new Document(PageSize.A2, 7f, 7f, 7f, 0f);

HTMLWorker htmlparser = new HTMLWorker(pdfDoc);

PdfWriter.GetInstance(pdfDoc, Response.OutputStream);

pdfDoc.Open();

htmlparser.Parse(sr);

pdfDoc.Close();

Response.Write(pdfDoc);

Response.End();

}

Demo for PDF document

If you observe above code I added one function that is VerifyRenderingInServerForm this function is used to avoid the error like “control must be placed in inside of form tag”. If we setVerifyRenderingInServerForm function then compiler will think that controls rendered before exporting and our functionality will work perfectly

Download : sample code attached
Now if you’re getting any error message please feel free to let me know ?

Exporting grid data to Word and Excel using asp.net

Introduction: 
Here I will explain how to export gridviewdata to Word and Excel using asp.net.

Description:

I have one gridview that has filled with user details now I need to export gridview data to word or excel document based on selection. To implement this functionality first we need to design aspx page like this

<html xmlns=”http://www.w3.org/1999/xhtml”&gt;

<head id=”Head1″ runat=”server”>

<title></title>

</head>

<body>

<form id=”form1″ runat=”server”>

<div>

<table>

<tr>

<td align=”right”>

<asp:ImageButton ID=”btnExcel” runat=”server” 

ImageUrl=”~/ExcelImage.jpg”

onclick=”btnExcel_Click” />

<asp:ImageButton ID=”btnWord” runat=”server” 

ImageUrl=”~/WordImage.jpg”

onclick=”btnWord_Click” />

</td>

</tr>

<tr>

<td>

<asp:GridView runat=”server” ID=”gvdetails” DataSourceID=”dsdetails”  

AllowPaging=”true”AllowSorting=”true” AutoGenerateColumns=”false”>

<RowStyle BackColor=”#EFF3FB” />

<FooterStyle BackColor=”#507CD1″ Font-Bold=”True” 

ForeColor=”White” />

<PagerStyle BackColor=”#2461BF” ForeColor=”White” 

HorizontalAlign=”Center” />

<HeaderStyle BackColor=”#507CD1″ Font-Bold=”True” 

ForeColor=”White” />

<AlternatingRowStyle BackColor=”White” />

<Columns>

<asp:BoundField DataField=”UserId” HeaderText=”UserId” />

<asp:BoundField DataField=”UserName” HeaderText=”UserName” />

<asp:BoundField DataField=”LastName” HeaderText=”LastName” />

<asp:BoundField DataField=”Location” HeaderText=”Location” />

</Columns>

</asp:GridView>

</td>

</tr>

</table>

<asp:SqlDataSource ID=”dsdetails” runat=”server”ConnectionString=”<%$ConnectionStrings:dbconnection %>

SelectCommand=”select * from UserInformation”/>

</div>

</form>

</body>

</html>

Here don’t forgot to set the connection string in web.config file here I am getting database connection from web.config file for that reason you need to set the connectionstring in web.config file like this 

<connectionStrings>

<add name=dbconnection connectionString=Data Source=SD;Integrated Security=true;Initial Catalog=MySampleDB/>

</connectionStrings>

After set the connection string in web.config file now we are able to get the data from database and we can bind that data to gridview by using sqldatasource. Now if you run application gridview appears like this

 

Now in code behind add this reference

using System.IO;

After that write the following code in code behind


public override void VerifyRenderingInServerForm(Control control)

{

/* Verifies that the control is rendered */

}

/// <summary>

/// This event is used to export gridview data to word document

/// </summary>

/// <param name=”sender”></param>

/// <param name=”e”></param>

protected void btnWord_Click(object sender, ImageClickEventArgs e)

{

gvdetails.AllowPaging = false;

gvdetails.DataBind();

Response.ClearContent();

Response.AddHeader(“content-disposition”string.Format(“attachment; filename={0}”,“Customers.doc”));

Response.Charset = “”;

Response.ContentType = “application/ms-word”;

StringWriter sw = new StringWriter();

HtmlTextWriter htw = new HtmlTextWriter(sw);

gvdetails.RenderControl(htw);

Response.Write(sw.ToString());

Response.End();

}

/// <summary>

/// This Event is used to export gridview data to Excel

/// </summary>

/// <param name=”sender”></param>

/// <param name=”e”></param>

protected void btnExcel_Click(object sender, ImageClickEventArgs e)

{

Response.ClearContent();

Response.Buffer = true;

Response.AddHeader(“content-disposition”string.Format(“attachment; filename={0}”“Customers.xls”));

Response.ContentType = “application/ms-excel”;

StringWriter sw = new StringWriter();

HtmlTextWriter htw = new HtmlTextWriter(sw);

gvdetails.AllowPaging = false;

gvdetails.DataBind();

//Change the Header Row back to white color

gvdetails.HeaderRow.Style.Add(“background-color”“#FFFFFF”);

//Applying stlye to gridview header cells

for (int i = 0; i < gvdetails.HeaderRow.Cells.Count; i++)

{

gvdetails.HeaderRow.Cells[i].Style.Add(“background-color”“#507CD1”);

}

int j = 1;

//This loop is used to apply stlye to cells based on particular row

foreach (GridViewRow gvrow in gvdetails.Rows)

{

gvrow.BackColor = Color.White;

if (j <= gvdetails.Rows.Count)

{

if (j % 2 != 0)

{

for (int k = 0; k < gvrow.Cells.Count; k++)

{

gvrow.Cells[k].Style.Add(“background-color”“#EFF3FB”);

}

}

}

j++;

}

gvdetails.RenderControl(htw);

Response.Write(sw.ToString());

Response.End();

}

Demo for Word document

 

If you observe above code I added one function that is VerifyRenderingInServerForm this function is used to avoid the error like “control must be placed in inside of form tag”. If we setVerifyRenderingInServerForm function then compiler will think that controls rendered before exporting and our functionality will work perfectly.

Here I used basic code to export gridview data to word document and for excel code is different but we can use the same code (Export to Word) for excel also to import gridview data just by replacingCustomers.doc to Customers.xls and application/ms-word to application/ms-excel but here we have problem that is row background color is applied throughout excel for that reason I made some small code modification and applied color only to the particular columns based on rows.

Demo for Excel document

 

Download : sample code attached

Now if you’re getting any error message please feel free to let me know ?

Debugging : How To Configure IIS 7.0 and Tomcat on Windows Server 2008

Question/Problem : How To Configure IIS 7.0 and Tomcat on Windows Server 2008
I have a Website designed in ASP.NET 3.0 and have another application in Java and after i read your some of the bogs came to know about the dependencies of java and dotnet so decided to combine both of the application in a single one web application. Actually Website in ASP.net is a Bio Portal and the application in java is a webmail Portal. since both are right at there places but the problem is that java based webmail needs Apache tomcat for execution as a must and have installed Bio Portal on a domain hosted on IIS 7.0 (Windows server 2008). is unable to interrelate both the technologies into one. could any one can help me.

Solution : For the purposes of this installation guide I used Java Runtime Version 6 Update 21, Apache Tomcat 6.0.29 and the Microsoft IIS Application Request Routing (ARR) 2.0 module.

You can download the software that I used in this guide from the following locations :

1. Java JRE Version 6 Update 21 (If have installed this go to point 2)
http://www.oracle.com/technetwork/java/javase/downloads/index.html

2. Apache Tomcat (32-bit/64-bit Windows Service Installer) (If have installed this go to point 3)
http://tomcat.apache.org/download-60.cgi

3. IIS Application Request Routing (ARR) 2.0 (If have installed Proceed from here to next)
http://www.iis.net/download/applicationrequestrouting

Start by installing the Java runtime (JRE) and accept the license agreement.

Then change the installation target folder to C:\Java and then click OK and wait while Java installs

Once you have installed Java you can start installing Tomcat. Double-click the apache-tomcat-6.0.29.exe file to invoke the Apache Tomcat Setup Wizard.

Choose a Custom installation and ensure that the Examples are selected as shown here. You wouldn’t necessarily want to install the sample applications in a production environment but we will be using them in this walkthrough so we need to install them.

Select to install Tomcat in the C:\Tomcat folder as shown here and then click Next.

Leave the default HTTP/1.1 Connector port set to 8080 and choose a password for the admin account.

The setup wizard should find your Java installation automatically.

Click install and wait while Tomcat setup completes. When the installation is complete click Finish.

Now that you have Tomcat up and running you can test your installation by pointing your server’s browser at http://localhost:8080 and you should see the default Apache Tomcat welcome page as shown here.

Now that we have got Tomcat working

Now the configuration of IIS 7.0 and Tomcat can be done with two ways

  1. using IIS ARR Module
  2. Using JK 1.2 ConnectorWe will be proceding for the solution step by step, so let us start our first step using IIS ARR Module.

1. How To Configure IIS 7.0 and Tomcat with the IIS ARR Module

we need to install and configure the IIS Application Request Routing module which will allow IIS to act as a proxy server and forward requests on to Tomcat. Run the ARRv2_setup_x86_en-us.EXE file (or ARRv2_setup_amd64_en-us.EXE if you are using 64-bit Windows) to begin the ARR setup routine.

When the ARR module installation has completed it will create a log file (arr_setup.log) which can be found the %TEMP% folder.

Now that the Application Request Routing (ARR) module has been installed we need to configure it to act as a proxy server (this functionality isn’t enabled by default). In IIS Manager highlight the Application Request Routing Cache feature and click Open Feature in the Actions pane.

Click Server Proxy Settings in the Actions pane.

Tick the Enable proxy checkbox and then click Apply. Leave all the default values in place.

Next we need to configure a URL Rewrite rule so that IIS knows what to do with requests which we want to forward to Tomcat. Click the Default Web Site, highlight the URL Rewrite icon and then click Open Feature in the Actions pane.

In the URL Rewrite feature click Add Rules in the Actions Pane.

In the Add Rule(s) dialog box select Blank rule and click OK.

In the Edit Inbound Rule feature assign a name to the new rule and type (examples.+) in the Pattern dialog box. The new rule should default to using Regular Expressions (if it doesn’t ensure that you select this option)

In the Action section of the Edit Inbound Rule feature ensure that the Action type is set to Rewrite and then enter http://localhost:8080/{R:0} in the Rewrite URL dialog box as shown below. Click Apply to create the new rule.

Everything we need to configure is now in place and we are ready to test. Start by browsing the ‘Request Headers’ sample application from Tomcat directly on port 8080 with the result shown here.

The final step is to browse the same ‘Request Headers’ sample application on port 80 so that the request will be handled by IIS before being forwarded to Tomcat by the ARR proxy. If everything is configured correctly you should see the sample application load successfully as shown here.

If you now examine the IIS log file (which can be found in C:\inetpub\logs\LogFiles by default) you will see that the request for the Tomcat sample application was processed by IIS and proxied by the ARR module. The IIS log file contains both the X-ARR-CACHE-HIT and X-ARR-LOG-ID details as shown here.

Using the IIS ARR module means that there is no longer any need to use the Tomcat JK 1.2 ISAPI Connector. However, I would always recommend that you test your application rigorously before deploying it in a production environment. If you do find any issues with ARR you can always get support in the IIS ARR forums here :

http://forums.iis.net/1154.aspx

2. How To Configure IIS 7.0 and Tomcat with JK 1.2 Connector

Now we need to configure the JK 1.2 Connector which will allow IIS to effectively act as a proxy and forward requests on to Tomcat. Start by creating a folder called ‘ISAPI’ under the Tomcat root folder. Then copy the isapi_redirect-1.2.28.dll file into the ‘ISAPI’ folder and rename the file to isapi_redirect.dll as shown here.

In order to configure the Tomcat connector you need to either add an entry in the Windows registry or you can use the isapi_redirect.properties file. The isapi_redirect.properties file tells the connector where to find its configuration files and also where the isapi_redirect DLL file is located. If you have used the same directory structure as I have you can configure your isapi_redirect.properties file as shown here.

We also need to either update or create the two Tomcat connector configuration files (workers.properties and uriworkermap.properties) so that the connector knows how to handle the requests it receives. These configuration files are documented on the Tomcat web site here : The Apache Tomcat Connector – Reference Guide
If you have just installed Tomcat with the sample applications then you can copy the sample uriworkermap.properties file shown here. Both config files need to placed in the Tomcat ‘conf’ folder which in this example is C:\Tomcat\conf

You can also copy the sample workers.properties file as shown below and save it to the C:\Tomcat\conf folder.

Now we need to configure IIS. Start by creating a virtual directory and give it an alias of ‘jakarta’ as shown here. Incidentally, you don’t have to call the virtual directory ‘jakarta’ – you can actually give it any name you like, just so long as the name you choose appears in the extension_uri line of your isapi_redirect.properties file.

Next we need to configure the virtual directory to have execute permission. This was a simple tick-box option in IIS 6.0 but in IIS 7.0 we need to click on the Jakarta virtual directory and then double-click Handler Mappings.

Within the Handler Mappings feature click Edit Feature Permissions in the Actions Pane.

Click Execute in the Edit Feature Permissions dialog box and click OK.

In the Handler Mappings feature you can now see that calls to ISAPI-dll files are enabled.

The next step is to add an ISAPI filter on the web site. To do this click on the web site and then double-click the ISAPI Filters feature.

In the Actions pane click Add.

In the Add ISAPI Filter dialog box enter a name and the path to the isapi_redirect.dll file and click OK.

The Tomcat ISAPI filter should now appear in the ISAPI Filters list as shown here.

The final step we need to take is to configure the ISAPI and CGI Restrictions feature in IIS 7.0. This is analogous to adding or allowing a Web Service Extension in IIS 6.0. In IIS Manager navigate to the Server Home and then double-click on the ISAPI and CGI Restrictions feature.

In the ISAPI and CGI Restrictions feature click Add on the Actions pane.

In the Add ISAPI or CGI Restriction dialog box enter a name and the path to the isapi_redirect.dll file, tick the Allow extension path to execute option and click OK.

The Tomcat ISAPI extension should now appear in the list with a Restriction status of allowed as shown here.

Everything we need to configure is now in place and we are ready to test. I started by requesting the ‘Hello World’ sample application from Tomcat directly on port 8080 with the result shown here.

The final step is to request the same ‘Hello World’ sample application using port 80 so that the request will be handled by IIS before being forwarded to Tomcat. If everything is configured correctly you should see the sample application load successfully as shown here.

If you now examine the IIS log file (which can be found in C:\inetpub\logs\LogFiles unless you moved it) you will see the request for the sample application being handled by IIS over port 80. One behaviour change that I have noticed is that the actual resource being requested isn’t logged with IIS 7.0 whereas it was in IIS 6.0, although I think this is likely to be a change in the bahviour of the ISAPI filter itself rather than any change in how IIS logs requests.

That’s It. I think it will help all of my visitors to have the solution for their problems. If have any Problems please feel free to post comments right here.

A list of top 10 and Best FREE Webmail for your Website

10 Best FREE Webmail for your Website

Webmail’s software’s are scripts which run on your servers and give you browser based mail client interface like Gmail, Yahoo etc. There are several free webmail scripts available for php/mysql. They are especially useful in checking mails on the go, also when you have several employees and want everyone to have their own email under same domain, it can be easier for employees to login. Also as you’ll be using your own server the limit of storage will be your hosting servers limit itself, so it’s useful in you get lots of emails with big attachments and no free email service is offering enough space to store them.

Round Cube

It is a multilingual web based email client for PHP/MySQL. It offers a wide variety of features and is open source.

  • Full HTML email support
  • Multilingual with over 60+ languages
  • Search suggest address book
  • HTML message composing
  • Threaded Message
  • Shared folders
  • Can be extended using plugin api

Xeams

Secure and powerful mail server with multi OS support, currently it supports Windows, Linux, Solaris, MacOSX and other flavors or UNIX. Also comes with Spam filtering mechanism and is completely free.

  • Multi OS support
  • 99% spam protection
  • SMTP, POP3 and IMAP support
  • Policy Enforcement
  • Message Archiving

Claros inTouch

Open source ajax communication suite with built in messenger, rss, calendar, post-it support. It is created on java technology so your server need to have JAVA 2 SDK installed.

  • Live Messenger
  • Multiplatform Support
  • Multilingual
  • Post It Notes
  • RSS
  • Built In Spam Protection
  • Can be extended using plugin api

Conjoon

Full featured web based application for webmail with folder management, editor, feed reader, web 2.0 mashups and tabbed browsing. Built in ExtJs and Zend Framework and is completely free.

  • Browser Compatibility
  • Twitter Module
  • Tabbed Browsing
  • Intelligent Caching
  • Feeds Module
  • Wizard based installation

At mail

Free open source webmail written in PHP. Written to make it light weight yet powerful application. Also offers video mail and is multilingual.

  • Lightweight
  • Video Mail
  • Live Spell Check
  • HTML email Composing
  • LDAP address book

Xuheki

IMAP Browser based client for your email server. Licensed under GNU GPL and having a complete ajax interface. The main drawback is no support for POP3.

  • Multiple Folder
  • Browser Support
  • HTML Editor
  • Search & Sort
  • Excellent MIME Support

Zimbra

Zimbra claims to be the most capable open source email and collaboration suite available today. Comes with Rich AJAX integration and has global address lists, shared calendars and document management on the web or offline with Zimbra Desktop.

  • HTML Email
  • Mobile Support
  • Sharing and Document Management
  • Powerful Administration
  • Group Calendars

Exemis

It is a skin for well-known squirrel mail which comes bundled with most of cpanel hosts. It transforms the squirrel mail into user-friendly mail.

  • Plugin Support
  • No JavaScript required
  • Ajax Interface

Crystal Mail

Based on Roundcube it improves over the original interface. Released under GNU GPL 3.0 License. Claims to be world’s best webmail client. Also comes with 3 column layout.

After Logic Mail

After Logic Comes with a bundled package consisting of

E-mail Components

1. MailBee.NET Objects
Brings e-mail capabilities to your .NET applications in a few lines of code. You may choose a part of MailBee.NET Objects by standard (SMTPPOP3,IMAPSSLAntiSpamOutlook) or by task:create and sendreceiveparsemanage IMAP,protectbulk e-mails, make them safeprotect from spam, convert to Outlook .MSG or to PDF.

For developers who use classic ASP, Delphi or VB6, we offer ActiveX version – MailBee Objects.

WebMail

2. AfterLogic WebMail Pro
Webmail front-end for your existing POP3/IMAP mail server. It uses powerful AJAX interface for faster access to your emails. Available for both major web platforms: ASP.NET (Windows only) and PHP (Linux/Windows).

Complete E-mail Solution

3. AfterLogic MailSuite Pro for Linux
This messaging and collaboration solution includes a web-based admin panel, an SMTP/POP3/IMAP server (MTA), anti-spam and anti-virus protection, plus all the features of AfterLogic WebMail Pro, such as AJAX-based webmail, personal calendars, contacts, and more. It ships as a self-contained installation package for a quick and effortless setup, and available as a free trial.

There are many other paid solutions available which may be better than the above listed mail scripts. If you have come across a good script let us know!

Creating Self Email Company like Gmail and Hotmail

Create your own Email Company like Gmail and Hotmail

 

Gmail and Hotmail provides great free email service. They both provide many free tools with their email service. Have you ever thought to create your own email company like Gmail, Hotmail? Yeah ! Many times, but didn’t find any good site to do this. Here is the guide to create your own professional email service like Gmail and Hotmail. All you must have is a domain name and good knowledge of Internet. We will do this by registering with Windows Live Domains which provides 500 free email accounts with 5 GB Space in each account and with many free services.

gmail hotmail 300x200 Create your own Email Company like Gmail and Hotmail

Steps to Create your own Email Company:

First of all, Go to https://domains.live.com. It requires your Hotmail Username and password, so keep them ready. Now, you have reached the Windows Live Admin Center, Click “Sign in”, at the login page, enter your Hotmail email address and password then click “Sign in”. I have registered two domains at there, so I will get a different page then the new ones. Click “Add Domain” button, then you will get a page saying “Create a Windows Live experience for your domain”. Enter your domain name in the field labeled “Provide your domain name” and mark the “Set up Windows Live Hotmail for my domain” and click “Continue”.  Now, you’ve reached the page “Review settings and accept agreement”, Click “I accept”. Then you will be redirected to the “Domain Settings” page. Now, all the settings in the Windows Live Domains have been setup, now go to your “Domain Manage” panel and change MX Records.

What happens after 500 Email accounts exceeded?

Windows Live Domains provides 500 email accounts, so you (and other users) can create 500 email accounts, what if you exceed this? The solution is available. Windows Live Domains provides more email accounts on the request of the domain admin. So, when you exceed it, just ask for more accounts.

Promote your Email Service:

email promote TechListen Create your own Email Company like Gmail and Hotmail

After getting email service, it’s time to promote it. Promote it on your blog/website, in emails, on business cards, etc. way. The more you promote, the more users you’ll get. You are not getting just the Email service for your domain, but you are getting lots of services free with it. You get SkyDrive (25 GB Free Space), Photos, etc. So, attract your visitors with these free services.

If you have any question about this process, then please let me know by commenting here. I will be happy to assist you icon smile Create your own Email Company like Gmail and Hotmail

How to make a Video and Audio Player for Website

Download Source File : Creating Audio and Video Player using SWFObject JS Libraries

Before start creating our players first we have to have a list of the items or variables we need to create this amazing Players for our website. We will be in need of the items as follows :-

jpg : Archieve for image jpg

flv : FLV Archieve for Multimedia file

mp3 : Archieve for audio MP3

SWFObject : Archieve for SWFObject js Library

Now include the code into your page after body tag

<h2>Video Player</h3>

<hr />

<div id=”Flashplayer”></div>

<script type=”text/javascript”>

var so = new SWFObject(“video_player.swf”, “swfplayer”, “400”, “327”, “9”, “#000000”);

so.addVariable(“flv”, “video.flv”);

so.addVariable(“jpg”,”imagen.jpg”);

so.addVariable(“autoplay”,”false”);

// so.addVariable(“autoplay”,”true”);

so.addParam(“allowFullScreen”,”true”);

so.write(“Flashplayer”);

</script>

<hr />

It will show you the video player as desired by you, you can make some of the changes by applying into the attributes of your objects used. As mentioned any of the property can be blocked by giving // tags and it will be listed out from the execution of the code.

And for the creation of the audio player include the code into your page after body tag

<h2>Audio Player</h3>

<hr />

<div id=”mp3player”></div>

<script type=”text/javascript”>

var so = new SWFObject(“audio_player.swf”, “swfplayer”, “400”, “27”, “9”, “#FFFFFF”);

so.addVariable(“mp3”, “audio.mp3”);

so.addVariable(“autoplay”,”true”);

so.addVariable(“effect”,”false”);

so.addVariable(“backcolor”,”FFFFFF”);

so.addVariable(“frontcolor”,”1864AF”);

so.addVariable(“fullscreen”,”false”);

so.addParam(“allowFullScreen”,”true”);

so.write(“mp3player”);

</script>

and now comes the time for the makeup of our players, so for this use the style sheet

body{ font-family:Arial, Helvetica, sans-serif; font-size:12px; margin:20px; }

a { color: #1864AF; text-decoration:none; }

a:hover { text-decoration:underline; }

So at the end our code becomes like this :-

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>

<html xmlns=”http://www.w3.org/1999/xhtml”&gt;

<head>

<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />

<title>Audio Player</title>

<script src=”includes/swfobject.js” type=”text/javascript”></script>

<style type=”text/css”>

body{ font-family:Arial, Helvetica, sans-serif; font-size:12px; margin:20px; }

a { color: #1864AF; text-decoration:none; }

a:hover { text-decoration:underline; }

</style>

</head>

<body>

<h2>Video Player</h3>

<hr />

<div id=”Flashplayer”></div>

<script type=”text/javascript”>

var so = new SWFObject(“video_player.swf”, “swfplayer”, “400”, “327”, “9”, “#000000”);

so.addVariable(“flv”, “video.flv”);

so.addVariable(“jpg”,”imagen.jpg”);

so.addVariable(“autoplay”,”false”);

// so.addVariable(“autoplay”,”true”);

so.addParam(“allowFullScreen”,”true”);

so.write(“Flashplayer”);

</script>

<hr />

<h2>Audio Player</h3>

<hr />

<div id=”mp3player”></div>

<script type=”text/javascript”>

var so = new SWFObject(“audio_player.swf”, “swfplayer”, “400”, “27”, “9”, “#FFFFFF”);

so.addVariable(“mp3”, “audio.mp3”);

so.addVariable(“autoplay”,”true”);

so.addVariable(“effect”,”false”);

so.addVariable(“backcolor”,”FFFFFF”);

so.addVariable(“frontcolor”,”1864AF”);

so.addVariable(“fullscreen”,”false”);

so.addParam(“allowFullScreen”,”true”);

so.write(“mp3player”);

</script>

<hr />

</body>

</html>

that’s it, our players are complete to test and have fun.

Download Source File : Creating Audio and Video Player using SWFObject JS Libraries

A Detailed Discussion Over CSS Filters

Little About This Post

without the discussion of CSS Filters, the story started with two previous blog posts

A Detailed Discussion Over Exploring CSS Refreshers : Borders

A Detailed Discussion Over CSS Preprocessors

would have not completed, so i came to know much more in exploration from one of my favourite blogger, Writer Jeffrey Way. then getting some and writing more about the topic could be a beneficial approach for all visitors.

Tutorial Details

Earlier this month, a new specification, Filter Effects 1.0, was released. It presents some exciting new Photoshop-like effects that we can use in the browser. Even better, Webkit has already landed support (in the nightlies)!


According to the Spec…

“A filter effect is a graphical operation that is applied to an element as it is drawn into the document. It is an image-based effect, in that it takes zero or more images as input, a number of parameters specific to the effect, and then produces an image as output.”

Now, at least at this point, I wouldn’t presume to be able to show you everything that’s possible with these new filters. I’m still learning them myself! That said, I’ll show you a handful of the new filters, how we can use them in our projects, and then, hopefully, we can all brainstorm and learn from each other within the comments. Let’s get started.

Filters are typically associated with images (though they can also be applied to video). As such, for the handful of demos below, we’ll be using the Nettuts+ logo as input.

Nettuts+ Logo

Remember: these effects aren’t yet available in the public releases of Webkit browsers. For now, download Canary when testing these demos.


hue-rotate

Ever played around with the Hue/Saturation panel in Photoshop? Well now you can play around with it in the browser.

  1. img {
  2.    -webkit-filter: hue-rotate(50deg);
  3. }

If specifying this value in degrees seems confusing, just imagine a color wheel. The number of degrees you specify determines where that wheel stops. This means, that 0deg won’t do a thing, while 50deg will turn the dial, accordingly.

In this case, the Nettuts+ logo will take on a blu-ish hue.

Or, let’s say that you want your image to continuously change colors. Likely, in a real-world project, the color transitions will be far more subtle, but for this demo, we’ll be a bit obnoxious.

  1. img {
  2.    -webkit-animation: adjustHue 1s alternate infinite;
  3. }
  4. @-webkit-keyframes adjustHue {
  5.    0% { -webkit-filter: hue-rotate(30deg); }
  6.    50% { -webkit-filter: hue-rotate(60deg); }
  7.    100% { -webkit-filter: hue-rotate(90deg); }
  8. }

Simple enough. View Demo


grayscale

We’ve used a variety of hacks in the past to transition an image from black and white to color in the browser. One technique calls for two images stacked on top of one another. Another option is to use canvas. Or… we can use the grayscale filter.

  1. img {
  2.    -webkit-filter: grayscale(100%);
  3. }

When applying a percentage to the grayscale function, just think to yourself, “On a scale of 0 to 100%, how gray do I want this image to be?

When used in tandem with CSS3 transitions, we can apply a nice and clean hover effect.

  1. img {
  2.   -webkit-transition: -webkit-filter 1s;
  3. }
  4. img:hover {
  5.     -webkit-filter: grayscale(100%);
  6. }

In the future, you’ll want to provide prefixes for the other browsers, however, it’s not necessary at this point. No need in applying Mozilla transitions to accomodate for a filter that’s only implemented in Webkit (so far).

View Demo


sepia

Enjoy the sepia-flavored Instagram effect? Let’s see what Nettuts+ looked like in the old west.

  1. img {
  2.       -webkit-filter: sepia(100%);
  3. }

Typically, though, this effect is applied to photos. Let’s see how the greatest artist who ever lived looks in sepia.

Excellent.


blur

By passing a radius, we can blur an image in the browser with ease.

  1. img {
  2.       -webkit-filter: blur(2px);
  3. }

Or by upping the blur radius to 50px.


brightness

We use the brightness filter to specify…wait for it…how bright the input image should appear.

  1. img {
  2.       -webkit-filter: brightness(15%);
  3. }

Think of 100% as home base. brightness(100%) keeps the image unchanged. As we reduce this percentage, however, the image will continue to darken.

Don’t forget: you can combine all of these filters.

  1. img {
  2.       -webkit-filter: brightness(60%) sepia(100%);
  3. }

contrast

We can now adjust the contrast of an image quite easily.

  1. img {
  2.       -webkit-filter: contrast(200%);
  3. }

Once again, think of 100% as resting position. We can then reduce or increase this value to adjust the contrast of the image. According to the spec, applying a value of 0% should make the image 100% black, similar to what you might expect from -webkit-filter: brightness(0%);. However, I’m seeing more of a dark gray.

  1. img {
  2.       -webkit-filter: contrast(0%);
  3. }

Now if we up the percentage considerably, to 2000%:

  1. img {
  2.       -webkit-filter: contrast(2000%);
  3. }

Just for fun, let’s create a throbbing Matrix version of the Nettuts+ logo. We’ll combine CSS3 animations and filters.

  1. img {
  2.     -webkit-animation: bluePill 1s alternate infinite;
  3. }
  4. @-webkit-keyframes bluePill {
  5.    0% { -webkit-filter: contrast(2000%); }
  6.    100% { -webkit-filter: contrast(100%); }
  7. }

View Demo


invert

Mac users: press Control + Option + Command + 8. Notice how it inverts your screen (of course you noticed). I use this trick late at night when I’m reading on the computer, and my eyes are sore.

By applying a percentage of 100 to the new invert filter, we can achieve the exact same effect.

  1. img {
  2.       -webkit-filter: invert(100%);
  3. }

Note that 0% will leave the image unchanged.

Now, you could technically apply this to, say, the body of your website, and it would work. However, you’ll notice considerable slow down, and lose the ability to scroll the page. AKA – Don’t do it, except for fun.


saturate

In addition to setting grayscale(100%), we could also achieve a similar effect by desaturating the image entirely.

In this case, 100% is the unchanged state, at which point you can either decrease or increase this value. As such, reducing this value to 0% should remove all color from the image.

  1. img {
  2.       -webkit-filter: saturate(0%);
  3. }

Or, by upping the value to 700%:


That’s All For Now

Stay tuned to this article over the course of the next week. As these techniques are still super new, we all need time to figure out how to use them. I’ll update this article as I learn more!

%d bloggers like this: