Sharepoint Site Pages Readfile - asp.net

I have been tasked with creating a small website using SharePoint 2010 Site Pages via SharePoint Designer. I am bringing over my favorite html template, which loads and runs as expected (mostly), but I quickly ran into the following problem.
I typically use PHP to inject certain data into my page by reading directly from a local file. I have no experience with ASP, which appears to be the only method to accomplish this. I have searched the docs and so many sites but haven't found a clear-cut way to do this, and now my head is spinning. Can anyone help me with a simple process for reading a file into the middle of my html file as it gets served?
For example:
<html>
<body>
Here's my title
<inject file contents here>
Here's my footer
</body>
</html>
Thanks all, any help will be much appreciated!

You cannot do this out of the box. You will have to create a customised solution to do this, by implementing a custom controls for instance.
When you start using Sharepoint you need to change your mindset about whatever you used before. Believe me you don't want to pick a fight with Sharepoint, because the beast will win.
back to your problem I think you should be looking at Reusable Content.
Here is a description about it:
http://en.share-gate.com/blog/sharepoint-reusable-content-a-forgotten-beauty
Basically you have a list where you manage all your reusable content bits (sort of like your files).
And then in the Rich text editor for the page content you can then insert a snippet that inject your reusable content.
if the content changes all the places you are using the reusable content bits will also change.
So this behaviour is pretty much the same you get if using a file. Except it's the SharePoint Way.
Good luck

Related

css vs dreamweaver templates

what is the difference in performance between css templates and dreamweaver templates , or are they the same. Need to know which one gets indexed quicker by google.
I want to move my website to one the best templates for quick uploads and ftp linkups with linkmanagement tools
please advise
thanks
This is why I despise Dreamweaver and the alike...
Dreamweaver creates websites, which consist of HTML and CSS code, and maybe some JavaScript.
HTML: the "glue". It's the structure which browsers read.
CSS: the "perty stuff". It's what browsers read to determine how to make your page look (colors, layout, etc.).
Since Dreamweaver makes websites, a Dreamweaver template also helps Dreamweaver to make websites, which implies that it follows the above structure.
Templates just style your site and might provide some basic functionality, so they have nothing to do with uploads. Some might be bloated and cause slow loading times, but that's dependent upon the template.
In the end, Dreamweaver Template is more or less CSS + HTML.
A DW template file helps to isolate parts of your HTML code on a page/page basis. Editable content and "locked" content together (in hopes of making development quicker). If you like DW, and have a template you like - 0use it. But don't expect that to be your silver bullet.
There's no advantage to either template where search engines are concerned (good/bad content withstanding).
Content...(pertinent content) is what Google is after. Having a 1M file of valid content will beat a 200k file of sparse/bait-n-switch content every time (well, it's supposed to, right?).
The answer you are looking for: Every Dreamweaver template is a CSS+HTML template. So it depends on the CSS template you are using. For the most part Dreamweaver is pretty bad about writing optimal CSS and it also uses inline styles which is bad for performance.
The real answer: It is obvious you are a beginner and don't know how silly your question is, it is not even one question, and is open ended and has no answer. There is no such thing as a CSS template, CSS by itself is not enough to create a template and this is just a marketing word to use to sell templates to people looking for such a thing as a better alternative to HTML templates, and etc, there is CSS for a certain type of template or certain Document Object Model, so if that is your definition of a CSS template than every Dreamweaver Template is a CSS template, as Dreamweaver itself is not a web technology or language. Dreamweaver is a WYSIWYG/IDE that helps you to write CSS (and other code) without knowledge of CSS, or in my case I use it because I love the pink/purple syntax highlighting it has for CSS in code view.
*Need to know which one gets indexed quicker by google - FTP Upload - linkmanagement *
This has nothing to do with your question, you can create a website in notepad that gets better SEO results. You are mixing all these different concepts together, SEO, CSS, HTML Templates, google indexing,templates, quick uploads, ftp linkups, linkmanagement tools, these are all different concepts and each require years of experience for you to achieve this. At the end of the day what I am trying to tell you is, building a website as you describe is not a few clicks to create a template with dreamweaver. You first need to learn enough to be able to ask the right questions. And then you will be able to create such a website, not the best and ultimate "templates for quick uploads and ftp linkups with linkmanagement tools" but something that works, even though I'm not sure what exactly you are trying to build.
I Think you should look into a CMS like WordPress and get a nice looking wordpress template for your site and eventually become more familiar with these concepts. WordPress has a really good SEO/(google indexing as you say) that it even gets better results than expensive websites built by professionals. This is definitely what you want! trust me!
http://wordpress.org/

Using a Template for Web Page

We have a fairly large public website and have recently redsigned it with a new layout. The problem now is that with our redesign we find ourselves constantly hardcoding the html layout for all of our pages. This is clearly not the best solution.
My question is what are some options on ways to share/inherit, in a sense, a web template that all our ASP.Net projects can pull from for the layout. Specifically the HTML side of the layout. Any changes made to this template will update all web sites that use it. I'm sure this exists but do not know how to approach it.
Master Pages is what you are looking for. See: http://www.asp.net/master-pages/tutorials
or http://www.asp.net/master-pages/tutorials/creating-a-site-wide-layout-using-master-pages-vb
That's the technical solution. Oftentimes, the bigger challenge in retrofitting sites that were built with numerous one-offs is determining which parts of your pages belong in the master page or content areas. Keep in mind that you can have multiple content areas and you can provide default content in a master page that can later be overriden in a content page. It's very flexible. Have fun!
The simplest approach I know is to create a header and footer file for every page. Include the header just after the <body> tag and the footer just before </body>. You content goes in between.
I prefer a more sophisticated approach with a templating system like Smarty, but that's PHP. I don't know what your ASP options are.

Customizing GraffitiCMS

I downloaded GraffitiCMS the other day(now open source and free), and like a lot of what I see, but what I really want to use it for, is to add CMS capabilities to an existing asp.net database/application.
Without getting bogged down with all the details of my app, can someone give me the basic 'approach' that should be taken to add custom content to Graffiti; content that won't be a 'post'?
I've seen for example, how to add custom-widgets to Graffiti - basically inherit from the widget class, compile your dll and plop it into the correct directory and it becomes part of the system. Is there a way to do something similar for the main content areas?
For simplicity sake, pretend I have a non-graffiti database with gig's of data that I want to display on the website using standard asp.net grid's and forms. I realize I could just go in and hack apart the source code to integrate my existing app, but that is likely not the correct approach.
Not looking for a complete solution her, just a pointer and what areas to investigate...thanks.
If you check out the latest source of Graffiti (or the 1.3 branch that was recently created), support was added to put widgets anywhere you want on any page. There is a new chalk function - $macros.Widget - that provides you with this ability. Dan Hounshell wrote a blog post on how you can use this new functionality:
http://danhounshell.com/blog/graffiti-cms-1-3-add-a-widget-anywhere-in-a-view-with-new-widget-macro/
If you're looking for something different than that, just let me know - we're working to make Graffiti even better for situations just like you are currently in.
What we have done to be able to integrate Graffiti CMS with our current ASP.NET projects is to create a post in Graffiti called "hidden" and then with our standard .ASPX pages we call a class in our Render Override that pulls the "hidden" post (ie: site.com/hidden/) and uses the header and footer to wrap the Graffiti theme around our custom .ASPX page. We use some HTML comments in the "hidden" post to be able to parse the header and the footer. It is kind of a hack, but has worked out really well for us.
I think you're trying to put the cart before the horse - depending on the size and amount of functionality, I would be looking to rebuild it after learning the development platform of my CMS system of choice.
I'm pretty much in the same boat right now. I have avoided Graffiti because I have to learn "Chalk" (whatever that is) and Umbraco (using XSLT for layouts is retarded). So far, this leaves me with Sitefinity at the top of my list and Telerik have just pulled the free version!
I may end up grabbing a very basic CMS which is easier to customize. I know this doesn't directly answer your question, but it may give you some food for thought :-)

How to make embeddable code in ASP.Net

you must have seen widgets like code which people place inside their HTML and it starts showing a small widget in there, how we can we do it in ASP.net, for example if i want to show some specific data of my site to anywhere some specific code is placed, how can i generate that embeddable code that can start showing my specific block of data to anywhere from any site?
Here are a few methods used by various people to embed a snippet of content on an external website.
1) An iframe!
iframe's can be a right old pest, but are quite good at displaying a bit of external content. They have been added back into the HTML standards in the HTML 5 draft specification, so you should get futureproof support for them in the future.
<iframe src="http://www.widget-address.com/Widgets/SomeWidget/" title="Some Widget"></iframe>
You can style your iframe (give it a width and height) and all that jazz.
2) External Image
This is largely used by advertising engines. You pop an image on the page and the image is dynamically created to display some advert - each time it appears it is different. This isn't great if you want information to be screen-readable (i.e. accessible).
<img src="http://www.widget-addrees.com/Widgets/SomeWidget.jpg" alt="Some Widget">
3) Server Side API
You could make an API available so people can call a "service" on your site that supplies them with the information for the widget. For example, their ASP.NET code or PHP code (or whatever language) calls http://www.widget-address.com/Widgets/WidgetService/ and it returns some data that they can format and display on their page. This would give you the benefit of inline HTML, which is the most accessible and valid way of displaying the data.
There are lots of other methods, so if you don't fancy one of these, I'm sure more suggestions will flood in - including (be careful...) JavaScript / AJAX.
I'm not quite sure I understand the question, so I'm sorry if I'm way off here. But I guess you are using the webforms framework for asp.net? If you are there is something called server controls. Those can be used to create widgets like calenders for example (that is already included in the framework, so no need to build it again).
If you are looking for code block, similar to <?php [[code]] ?> in php (if you have used that), then the answer is <% %>. Those are code blocks in the .net world. If you want to write something out you use Response.Write("string to write"); inside the code block. Or you can use the faster way: <%="string to write"%> that will render the same think (string to write).
If you are using the webforms framework you can also take advantage of the built in server controls in the framework. You can read more about the framework here or simply google asp.net webforms.

How do I provide easy editing of ASP .NET master pages for designers?

Scenario:
I have a pretty standard master page for all my pages. It includes the usual login forms and other dynamic lists to be extracted on each page. Webdesigners can already modify the central content place holder of each page. But still, the design and layout for the master page is still in my project and any modification to the design must be made in Visual Studio and the project re-compiled and re-deployed.
What is the best way to provide near-full access to designing the master page through a CMS? Some of the problems I can identify is the inclusion of any dynamic lists or specific controls such as a login form.
Thanks.
Unless you want to host your content within a portal I don't know of a perfect answer to this.
If the bits they design just amount to look and feel for the page then this can be controlled by css and you could allow them to create themes using different css files.
This is indeed an interesting question, and there is no perfect solution. I worked for an ecommerce shop with this issue, and frankly, I just asked the designers in many cases to provide me there html and css, then I would grab the html pieces and css and add them to my project. Yes this was tedious....
Then we we built a cms where the designers could copy and paste their html into html editors, and we would store those pieces of html in a database. My web app would grab those from the database at run time. This solve some issues, but not all, since it did not give them complete control of the design of the web page.
The bottom line is you need to standard as to how the designer will submit their work to you. If you have that, and you can count on the html and css, then you can star to think of possibly building a CMS around that. In this days of RAD, I have found it easier to just work with the html and css delivered to me and simply copy and paste the pieces into my master page and other pages as needed.
While this is not a CMS answer, you do have the ability to allow designers to open the master pages in Expression Web. I will not say it is the greatest tool in the world, but I have had designers work up the master page designs in Expression with good results.
There is a pain point, however. If the entire project is opened, the designer will see the code behind files as separate items, not like the treeview view seen in Visual Studio.
I imagine you could have the master page checked out for use with Expression through a CMS, but there is no built in way to do this, nor do I know of a third party tool to do this. Hopefully Expression Web 3 will make things easier.
If you have a CMS, you may be better to give it full control over page content. If there are things the CMS cannot do, you could look to write extensions or plugin modules for the CMS that your designers can then drop onto the page in the CMS's page editor.
If your CMS doesn't support plugin modules, you may be trying to force both the CMS and master pages to do things they were not intended to do.
If the above doesn't work in your situation, here's another thought: place inline frames on your master page that host pages that are edited in the CMS.
Hope that helps.
Would it be possible for you to put placeholders in the Master Page in place of the areas that designers should be allowed to edit? Since Master Pages are only editable in Visual Studio, it may be your only feasible option at this point in time. One problem with this approach is that the content put in the placeholders is unlikely to be valid, since you would probably have tags left open in one placeholder and closed in another.
<html>
<head>
<title></title>
<asp:PlaceHolder ID="headerContent" runat="server"></asp:PlaceHolder>
</head>
<body>
<asp:PlaceHolder ID="beforeContent" runat="server"></asp:PlaceHolder>
<asp:PlaceHolder ID="centralContent" runat="server"></asp:PlaceHolder>
<asp:PlaceHolder ID="afterContent" runat="server"></asp:PlaceHolder>
</body>
</html>
I know it's ugly, but it might give you the control you need (as long as you don't mind the XHTML validator warning you all the time). What you put in the placeholders could be your user controls or literal content or whatever, but you'd have to load it dynamically.
Thoughts?
EDIT: This won't work. The PlaceHolder is going to render <div> tags that would mess things up. Maybe you could extend PlaceHolder and override how it renders its HTML.
Interesting question,
been dabbling in that area myself a while ago.
How knowledgeable are these web designers when not in the realm of not-inside-Photoshop-or-flash?
If using a DIY-CMS, perhaps you can template the most susceptible objects, e. g. making a generic (as in whatever you feel like, not whatever they feel like ;-)) list and a way of entering design, if applicable.
As long as you have a thorough framework set up, that deals with the attributes available to the designers through the CMS, there shouldn't be any need for recompiling... but of course, I can easily see a developer (read : me) stumbling
into the gap of nitty-pitty-perfection....
I'm afraid the easiest, and only manageable, path is to standardize how the designers express their needs&wants to you...it just won't code itself...
Could you provide some examples?
Well, with a Web Application Project pages are not compiled until accessed (link is 2005 but it still applies). This means that the actual .aspx (and .ascx etc) page is deployed in its original state. A designer can update the format of the page on the server and the updates will be compiled the next time someone requests that content.
It would be relatively trivial to allow designers to download the current pages and upload replacements through your website's UI. However, it isn't very secure (and probably should never be done). It would be better to allow designers access to the virtual directory over the web so they can connect to it using a tool such as Expression Web. This way the designer can open the current website, edit pages, and push the results directly into production (scary tho that thought may be).
As I'm getting downvoted for having a correct answer, let me point out something.
Website projects compile codebehind and pages on demand. If you need to update code regularly, its an okay solution.
Web application projects can be configured to be updatable. All codebehind and classes are compiled into an assembly, and all aspx, ascx, etc pages are deployed and compiled on demand. This means that a designer can connect to the website, update the layout and static content, and see the changes on the next request.
This is my preferred method of deployment. I have a few web application projects out there in the wild, with updatable aspx files deployed alongside my dll. The idea being that users of the website can alter the UI without having to submit updates to me so I can recompile it for them.
a .master is just a text file. They can edit it however they like. There's certainly nothing they'd do to it that would require you to recompile the code just to view it. That's the big win with Master Pages in the first place: designers and other non-programmers can edit them manually without breaking anything.
Give them access to the file under source control and let them go nuts.

Resources