Common 프로젝트 안에 Reply.Common 클래스 라이브러리 안에 Border.CS 클래스 파일 생성 GetNewImg() : 24 시간 내의 글이면 New 이미지 붙이기 ConvertContentByEncoding() : 인코딩 방식에 따른 Content 문자열 변환 |
Border.Cs |
using System;
// Common 에 구현 namespace Reply.Common { public class Board { /// <summary> /// 날짜값 받아서 24시간내의 글이면 New 이미지 붙이기 /// </summary> /// Reply.Common.Board.GetNewImg 써서 사용 public static string GetNewImg(object postDate) { TimeSpan ts = DateTime.Now - Convert.ToDateTime(postDate); string result = ""; if (ts.TotalHours < 24) // 24시간 내의 글이면... { result = "<img src='images/new.gif'/>"; } return result; } /// <summary> /// 인코딩 방식에 따른 Content 문자열 반환 : Text/Mixed/HTML /// </summary> /// <param name="content"></param> /// <param name="encoding"></param> /// <returns></returns> public static string ConvertContentByEncoding { string result = String.Empty; encoding = encoding.ToLower(); // 소문자로 비교 if (encoding == "Text") // 태그 실행 방지/소스 그대로 { result = content .Replace("&", "&") .Replace("<", "<") .Replace(">", ">") .Replace("\r\n", "<br />") .Replace("\t", " "); } else if (encoding == "Mixed") // 태그 실행 { result = content.Replace("\r\n", "<br />"); } else // HTML로 표시 { result = content; } return result; } } } |
'.Net Project > ASP.NET 3.5 Sp1' 카테고리의 다른 글
43장 데이터 컨트롤(ListView) (0) | 2009.10.27 |
---|---|
42장 데이터 컨트롤(ADO.NET) (0) | 2009.10.27 |
41-9장 답변형 게시판(Delete) (0) | 2009.10.27 |
41-8장 답변형 게시판(View) (0) | 2009.10.27 |
41-7장 답변형 게시판(Modify) (0) | 2009.10.27 |