Click here to Skip to main content
15,892,768 members
Articles / Programming Languages / C# 4.0

Microsoft Office Automation - Poor Man's SharePoint Server

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
3 Jan 2013CPOL3 min read 15.8K   331   9  
A poor man's SharePoint web solution allowing the upload and convertion of PowerPoint, Excel, Visio, and Word documents to HTML.
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="OfficeToHTMLWeb.SiteMaster" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<head runat="server">
    <title></title>
    <link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
    <asp:ContentPlaceHolder ID="HeadContent" runat="server">
    </asp:ContentPlaceHolder>

<script language="javascript">
    function previewURL(sender) {

        var preview = document.getElementById("PreviewDiv");
        preview.style.visibility = "visible";
        preview.style.left = event.clientX + "px";
        preview.style.top = event.clientY + "px";

        var iframe = document.getElementById("PreviewFrame");
        iframe.src = sender.href;

    }

    function closePreview(sender) {
        var preview = document.getElementById("PreviewDiv");
        preview.style.visibility = "hidden";
    }

    function viewLink(sender) {
        window.open(sender.href,sender.id);
    }

</script>
</head>

<body>
    <form runat="server">
    <div class="page">
        <div class="header">
            <div class="title">
                <h1>
                    My ASP.NET Application
                </h1>
            </div>
            <div class="loginDisplay">
                <asp:LoginView ID="HeadLoginView" runat="server" EnableViewState="false">
                    <AnonymousTemplate>
                        [ <a href="~/Account/Login.aspx" ID="HeadLoginStatus" runat="server">Log In</a> ]
                    </AnonymousTemplate>
                    <LoggedInTemplate>
                        Welcome <span class="bold"><asp:LoginName ID="HeadLoginName" runat="server" /></span>!
                        [ <asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect" LogoutText="Log Out" LogoutPageUrl="~/"/> ]
                    </LoggedInTemplate>
                </asp:LoginView>
            </div>
            <div class="clear hideSkiplink">
                <asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal">
                    <Items>
                        <asp:MenuItem NavigateUrl="~/Default.aspx" Text="Home"/>
                        <asp:MenuItem NavigateUrl="~/About.aspx" Text="About"/>
                    </Items>
                </asp:Menu>
            </div>
        </div>


        <div class="main">
            <asp:ContentPlaceHolder ID="MainContent" runat="server"/>
                <br />

                <strong><em>Uploaded Documents</em></strong>
                <asp:Panel runat="server" ID="OfficeUploadsPanel" width="100%" Visible="true" />

                <asp:Panel runat="server" ID="FileUploadsPanel" width="100%" Visible="true">
                    <hr />
                    <p>
                        <asp:FileUpload ID="FileUpload" runat="server" ondatabinding="Page_Load" />
                        <asp:Button ID="Upload" runat="server" onclick="Upload_Click" Text="Upload" />
                    </p>
                </asp:Panel>

                <br />
                <asp:Panel runat="server" ID="MyNotesPanel" width="100%" Visible="false">

                    <strong><em>My Notes for this Page</em></strong>
                    <br />
                    <div id="mynotes" style="display:block; border-bottom-width:thin;">

                        <asp:Table ID="Table1" runat="server" with="100%" HorizontalAlign="Left">
                            <asp:TableRow>
                                <asp:TableCell>
                                    Show the note below beginning on <asp:TextBox runat="server" ID = "NoteBegin" Width="80" /> but not after <asp:TextBox runat="server" ID = "NoteEnd" Width="80" />
                                </asp:TableCell></asp:TableRow><asp:TableRow>
                                <asp:TableCell>
                                    <asp:TextBox runat="server" ID="Note" TextMode="MultiLine" Height="60" Width="100%"/>
                                </asp:TableCell></asp:TableRow><asp:TableRow>
                                <asp:TableCell HorizontalAlign="Right">
                                    <asp:Button runat="server" ID="CreateNote" Text="Create" OnClick="CreateNote_OnCLick" />
                                </asp:TableCell></asp:TableRow><asp:TableRow>
                                <asp:TableCell>
                                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Note Begin date must be MM/DD/YYYY format and greater than 1900" ControlToValidate="NoteEnd" ValidationExpression="^\d\d/\d\d/(19|2\d)\d\d$" ForeColor="Red" />
                                    <br />
                                    <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ErrorMessage="Note End date must be MM/DD/YYYY format and greater than 1900" ControlToValidate="NoteEnd" ValidationExpression="^\d\d/\d\d/(19|2\d)\d\d$" ForeColor="Red" />
                                </asp:TableCell></asp:TableRow><asp:TableRow>
                                <asp:TableCell>
                                    <asp:Panel runat="server" ID="NotesPanel" Width="100%" BorderStyle="Solid" BorderWidth="1"></asp:Panel>
                                </asp:TableCell></asp:TableRow></asp:Table></div></asp:Panel></div><div class="clear">
        </div>

        </div>
        <div class="clear">
        </div>

        <div class="footer">        
        </div>
    

    <div id="PreviewDiv" style="visibility:hidden; position:absolute; left: 20%; top: 20%; width: 40%; height: 40%;">
        <iframe id="PreviewFrame" width="100%" height="100%" ></iframe>
    </div>
    </form>
</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions