Sunday, April 3, 2011

The simplest way to display PDF file in a web page, HTML object Tag

<object data="http://www.pdftest.test/test.pdf" height="360" type="application/pdf" width="600"></object>



Reference: http://www.w3.org/TR/html401/struct/objects.html
13.1 Introduction to objects, images, and applets

HTML's multimedia features allow authors to include images, applets (programs that are automatically downloaded and run on the user's machine), video clips, and other HTML documents in their pages.

For example, to include a PNG image in a document, authors may write:

<BODY>
<P>Here's a closeup of the Grand Canyon:
<OBJECT data="canyon.png" type="image/png">
This is a <EM>closeup</EM> of the Grand Canyon.
</OBJECT>
</BODY>

How to: Serialize and Deserialize JSON Data

http://msdn.microsoft.com/en-ca/library/bb412179.aspx

http://www.4guysfromrolla.com/articles/022311-1.aspx

Call ASP.NET Handler (ASHX) by JavaScript

Call ASP.NET Handler (ASHX) using JavaScript


<%@ WebHandler Language="C#" Class="SayHello" %>
using System;
using System.Web;

public class SayHello : IHttpHandler {
   
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";
        string param = context.Request.Params["Name"];
        context.Response.Write("Hello, " + param);
    }

    public bool IsReusable {
        get {
            return false;
        }
    }

}
JavaScript Code
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Call ASHX in JavaScript by DevCurry.com</title>
<script type="text/javascript">
    var httpReq = null;
    function callASHX() {
        httpReq = XMLHttpRequest();
        httpReq.onreadystatechange = XMLHttpRequestCompleted;
        httpReq.open("GET", "SayHello.ashx?Name=" +
            document.getElementById('<%=txtName.ClientID%>').value, true);
        httpReq.send(null);
    }

    // initialize XMLHttpRequest object
    function XMLHttpRequest() {
        var xmlHttp;
        try {
            // Opera 8.0+, Firefox, Safari
            xmlHttp = new XMLHttpRequest();
        }
        catch (e) {
            // IEBrowsers
            try {
                xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch (e) {
                try {
                    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                }
                catch (e) {
                    return false;
                }
            }
        }
        return xmlHttp;
    }

    function XMLHttpRequestCompleted()
    {
        if (httpReq.readyState == 4)
        {
            try
            {
                alert(httpReq.responseText);
            }
            catch (e)
            {
            }
        }
    }
</script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
       <asp:Button ID="btnCall" runat="server" Text="Enter Text and Click"
            OnClientClick="callASHX();"/>
    </div>
    </form>
</body>
</html>