http://weblogs.asp.net/alex_papadimoulis/default.aspx
From Alex Papadimoulis' Periodically Updated, Syndicated Website, over 3 years ago,
0 comments
Thought I'd share my review of James Avery's latest book ...
If you spend a fair amount of time writing code in Visual Studio.NET, then Visual Studio Hacks will definitely improve your productivity in writing, debugging, and maintaining code. You'll find everything from using (and the practical uses of) built-in features (such as the Clipboard ring) to in-depth explanations of downloadable add-ins.
One thing I love about the book is how easy the hacks are to implement. For example I've always been annoyed at the output from the build results window but never took the time to even think about changing it. It seemed to be just easier to deal with it than fix it. After reading Hack #35 (Modify the Build Output and Navigate the Results), I'm confident I can take a few minutes to write a macro and customize it as needed.
Worried about difficulty in writing a macro? Hack #51 explains it step-by-step.
Although I don't consider myself to be an Über-user of VS.NET, I do use the development environment quite a bit and know my way around fairly well. That said, Visual Studio Hacks has definitely augmented my knowledge of not only what VS.NET does, but what *good* 3rd party add-ins are available. I've had too many bad experiences with *bad* add-ins killing half-a-day of work after requiring a reinstall of VS.NET. The ones listed here work well and are documented well.
By the way, I have to say that I liked Hack #7 (Make Pasting into Visual Studio Easier) the most. But then again, it's pretty hard *not* like a hack that you contributed to the book ;-).
From Alex Papadimoulis' Periodically Updated, Syndicated Website, over 3 years ago,
0 comments
In this Community Server tip, I'll describe how to make a quick & easy home page that displays posts from one or more forums on one page.. If you're concerned that new visitors to your community will be turned off by the default listing of forums when they go to www.YourSite.com, then this just may be for you. I think you'll find that most of the time you spend on this tip will be in the actual design of the home page. This is what I do for TheDailyWtf.com.
Step One - LayoutThe standard default.aspx that comes with Community Server contains the title banner, site navigation tabs, and an area with some explanatory copy ("Community Server is a rich knowledge management and collaboration platform designed ..."). Keep as much or as little as you want; I opted to replace the main area with a two column view: a left "side-bar" and a center posts. Before you start coding, you may find it easier to put in dummy place holder post text where your normal posts would appear.
Step Two - Default.aspx HeaderAt the top of the top of the page, you'll want to make sure that you have the appropriate references to the Community Server components. Here is what I have at the top of my file. Some of these may or may not be already in the existing default.aspx:
<%@ Page SmartNavigation="False" Language="VB" %><%@ Register TagPrefix="CS" Namespace="CommunityServer.Controls" Assembly="CommunityServer.Controls" %><%@ Import Namespace="CommunityServer.Galleries.Components" %><%@ Import Namespace="CommunityServer.Blogs.Components" %><%@ Import Namespace="CommunityServer.Components" %><%@ Import Namespace="CommunityServer" %><%@ Import Namespace="CommunityServer.Discussions.Components" %>
<%@ Page SmartNavigation="False" Language="VB" %> <%@ Register TagPrefix="CS" Namespace="CommunityServer.Controls" Assembly="CommunityServer.Controls" %> <%@ Import Namespace="CommunityServer.Galleries.Components" %> <%@ Import Namespace="CommunityServer.Blogs.Components" %> <%@ Import Namespace="CommunityServer.Components" %> <%@ Import Namespace="CommunityServer" %> <%@ Import Namespace="CommunityServer.Discussions.Components" %>
Note that I have Language="VB" at the top. Although Community Server is entirely C#, I prefer to code in VB and will whenever I get a chance. Ahh, the power of .NET.
Step Three - Add The CodeJust place this block of code and place it under your page header Import statements:
<script runat="server">
dim sideBar as ThreadSet
dim main as ThreadSet
sub Page_Load
sideBar = Threads.GetThreads( _
18,0,5, Users.GetAnonymousUser(), _
DateTime.MinValue,SortThreadsBy.PostDate,SortOrder.Descending, _
ThreadStatus.Open, ThreadUsersFilter.All,false,false,false,false)
main = Threads.GetThreads( _
12,0,5, Users.GetAnonymousUser(), _
DateTime.MinValue,SortThreadsBy.PostDate,SortOrder.Descending, _
ThreadStatus.Open, ThreadUsersFilter.All,false,false,false,false)
DataBind
end sub </script>
The code is very basic. It declares two ThreadSets (a group of threads within a forum), fills them when the page loads, and then binds the thread sets to the repeater (which we will build in Step Four).
Since the GetThreads() arguments are a bit intimidating, I'll explain them one-by-one, in order:
forumID - The ID of the forum to get the threads for. For my site, 12 is the ID of the main forum and 18 is of the sidebar.You will definitely need to change this to the forum you'd like to display. pageIndex - Because a forum can contain more than one "page" of threads, you need to specify which page to retrieve. We're getting the threads from the first page, which is 0. pageSize - The number of threads to display per page. Both of my thread sets show five per page. user - The user who is requesting the threads. If you wanted, you could use the CurrentUser. I chose to display the threads as an anonymous user would have seen. I honestly think it makes little difference. threadsNewerThan - I want to show 5 threads, regardless of age. This is why I use DateTime.Min -- nothing can be older than that value. If you want to show the latest 10 days of threads, you could use Now.AddDays(-10) instead. sortBy - This refers to that drop down box in the sort options. Note that I'm using the custom one I discussed last time. sortOrder - This can be Ascending (old to new) or Descending (new to old). threadStatus - This can be Open, Closed, Resolved. You will most likely want Open userFilter - This can be All, HideTopicsParticipatedIn, HideTopicsNotParticipatedIn, HideTopicsByAnonymousUsers, or HideTopicsByNonAnonymousUsers. I think they're all pretty descriptive. activeTopics - true or false, indicates whether to show only active topics. An Active Topic is defined as (I believe) one where there was activity within the past seven days. I chose false. unreadOnly - true of false, indicates whether to only show unread. I think false is the best choice here. unansweredOnly - true of false, indicates whether to only show unanswered. I think false is the best choice here as well. returnRecordCount - true or false, indicates whether to return a record count or not. I said false because I'm not using a record count on the pageThat wasn't so bad, now was it?
Step Four - Add the Repeater(s)Now that we have the threadsets coded, we need to add some repeaters to display them. These are a very basic control to use. Here is a very basic code. As you can probably tell, this will have no styling whatsoever. This is all for you to add :-).
<asp:repeater runat=server datasource=<%#main.Threads%>> <itemtemplate> <h2><%#Container.DataItem.Subject%></h2> <div> <em><%#Container.DataItem.PostDate.ToLongDateString%></em>
<br/> <div><%#Container.DataItem.Body%></div> </div> </itemtemplate> </asp:repeater>
Note the datasource. Simply change that to whichever threadset (declared in step two) you'd like to display. Just play around with the formatting, and you're good to go. If you'd like, feel free to look at the source code of my default.aspx. Mostly you'll be able to see how I have links back to the post and some other things. It's pretty basic; you'll probably be able to figure it out by poking around.