'분류 전체보기'에 해당되는 글 159건
- 2010.05.03 [javascript] JSONP(JSON with Padding)을 이용한 Cross Domain URL 접근
- 2010.05.03 [CSS] IE 브라우저 버전별 CSS 적용
- 2010.04.30 [C#] Generic 의 활용
- 2010.04.29 [ASP.NET] 페이징
- 2010.04.29 [C#] 양력 / 음력 변환
- 2010.04.26 [ASP] HTTP Header를 이용한 파일 다운로드
- 2010.04.20 [ASP] asp에서 XML WebService 호출
- 2010.04.20 [C#] SQLCLR
- 2010.04.19 [Spring.Net] 로그 설정
- 2010.04.19 [Spring.Net] object 생성
2010. 5. 3. 17:50
2010. 5. 3. 15:48
출처 : http://virtuelvis.com/archives/2004/02/css-ie-only
IE 버전별 CSS 적용하기
<link rel="stylesheet" type="text/css" href="common.css" />
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="all-ie.css" />
<![endif]-->
<!--[if IE 6]>
<link rel="stylesheet" type="text/css" href="ie-6.0.css" />
<![endif]-->
<!--[if lt IE 6]>
<link rel="stylesheet" type="text/css" href="ie-5.0+5.5.css" />
<![endif]-->
<!--[if IE]>
<style type="text/css">
@import url(ie-styles.css);
</style>
<![endif]-->
2010. 4. 30. 17:27
솔직히 지네릭은 기존에 있는것만 사용했지
내가 만들어 쓴적은 거의(?) 없는 듯 하다.
잘만하면 정말 괜찮은 녀석인데 ㅋㅋ
생각만 잘하면 확장성 있게 쓸 수 있지 않을까 싶다.
public static T IIF<T>(bool compare, T a, T b)
{
return compare ? a : b;
(위 샘플은 3항 연산자를 써도 될듯 하지만 말이다...ㅋ){
return compare ? a : b;
}
2010. 4. 29. 17:09
어디서나 빠지지 않고 사용되는 페이징
참고 안하고 만들여보려니 절라 빡시단걸 알게 됐다.
이거 잘 만든 소스인지는 잘 모르겠네만.. 내가 만든거니 이거 쓸란다.ㅋㅋ
2010. 4. 29. 10:07
출처 : http://www.devpia.com/MAEUL/Contents/Detail.aspx?BoardID=18&MAEULNo=8&no=1228&ref=1228
--------------------------------------------------------------------------------------------------
//양력은 음력으로변환 테스트
private void button1_Click(object sender, EventArgs e)
{
label1.Text =음력변환(2007, 1, 1);
label2.Text = 음력변환(DateTime.Now);
}
//음력을 양력으로 변환 테스트
private void button2_Click(object sender, EventArgs e)
{
label2.Text = 양력변환(2006,11,13,false).ToShortDateString();
}
private string 음력변환(DateTime dt)
{
int n윤월;
int n음력년, n음력월, n음력일;
bool b윤달 = false;
System.Globalization.KoreanLunisolarCalendar 음력 =
new System.Globalization.KoreanLunisolarCalendar();
n음력년 = 음력.GetYear(dt);
n음력월 = 음력.GetMonth(dt);
n음력일 = 음력.GetDayOfMonth(dt);
if (음력.GetMonthsInYear(n음력년) > 12) //1년이 12이상이면 윤달이 있음..
{
b윤달 = 음력.IsLeapMonth(n음력년, n음력월); //윤월인지
n윤월 = 음력.GetLeapMonth(n음력년); //년도의 윤달이 몇월인지?
if (n음력월 >= n윤월) //달이 윤월보다 같거나 크면 -1을 함 즉 윤8은->9 이기때문
n음력월--;
}
return n음력년.ToString() + "-" + (b윤달 ? "*" : "") + n음력월.ToString() + "-" + n음력일.ToString();
}
private string 음력변환(int n양력년, int n양력월, int n양력일)
{
DateTime dTemp = new DateTime(n양력년, n양력월, n양력일); //양력
return 음력변환(dTemp);
}
private DateTime 양력변환(int n음력년, int n음력월, int n음력일, bool b달)
{
int n윤월;
System.Globalization.KoreanLunisolarCalendar 음력 =
new System.Globalization.KoreanLunisolarCalendar();
if (음력.GetMonthsInYear(n음력년) > 12)
{
n윤월 = 음력.GetLeapMonth(n음력년);
if (b달)
n음력월++;
if (n음력월 > n윤월)
n음력월++;
}
return 음력.ToDateTime(n음력년, n음력월, n음력일, 0, 0, 0, 0);
}
2010. 4. 26. 17:31
HTTP Header를 이용한 파일 다운로드
ASP.NET도 거의 코드가 동일한 가능하다.
Response.Clear()
Response.AddHeader("Content-Disposition", "attachment; filename=" & file.Name)
Response.AddHeader("Content-Length", file.Length.ToString())
Response.ContentType = "application/octet-stream"
Response.WriteFile(file.FullName)
Response.End
2010. 4. 20. 18:10
asp에서 다른 도메인(Cross Domain)의 데이터를 주고 받기 위한 방법으로도 사용된다.
(다른 방법으로는 JSONP를 이용할 수 있다.)
1. C#. XMLWebService 프로젝트로 XML 웹서비스를 개발한다.
- 도메인 : ws.cooldragon.co.kr
2. asp에서 웹서비스를 호출하는 클라이언트 페이지를 개발한다.
- 도메인 : www.cooldragon.co.kr
3. 개발된 사이트를 IIS를 설정한다.
4. 브라우저에서 테스트 해본다.
※ ws.cooldragon.co.kr, www.cooldragon.co.kr 은 가상의 도메인이며
예외 처리는 개발자의 몫으로 돌린다. ^^;;
-------------------------------------------------------------------------
1. [XML 웹서비스 개발]
2. [asp 개발]
<%
' 구현부
Dim reqTy
Dim url
Dim param
' 구현부
Dim reqTy
Dim url
Dim param
url = "http://ws.cooldragon.co.kr/Service1.asmx/SayHello"
param = "name=cooldragon"
Response.Write "result=" & CallWebService(url, param) & "<br/>"
url = "http://ws.cooldragon.co.kr/Service1.asmx/Sum"
param = "x=1&y=2"
Response.Write "result=" & CallWebService(url, param) & "<br/>"
url = "http://ws.cooldragon.co.kr/Service1.asmx/Subtract"
param = "x=1&y=2"
Response.Write "result=" & CallWebService(url, param) & "<br/>"
url = "http://ws.cooldragon.co.kr/Service1.asmx/HelloWorld"
param = ""
Response.Write "result=" & CallWebService(url, param) & "<br/>"
...
'웹서비스 호출 함수
Function CallWebService(url, param)
Dim result
Dim xmlhttp
Set xmlhttp = Server.CreateObject("MSXML2.XMLHTTP")
xmlhttp.Open "POST", url, false
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlhttp.send param
result = xmlhttp.responseText
set xmlhttp = nothing
CallWebService = result
End Function
%>
3. IIS 설정
- www.cooldragon.co.kr
- ws.cooldragon.co.kr
4. 실행결과를 확인할 수 있다.
참고URL :
http://www.codeproject.com/KB/asp/Web_Service_Call_From_ASP.aspx
2010. 4. 20. 12:17
공통모듈(컴포넌트)이 개발되면 여러 비지니스 로직에서 사용할 수 있다.
예를 들면 (COM+과 같은) 암호화 컴포넌트가 있는경우
암호화 컴포넌트는 asp, asp.net, sql server 2005(sqlclr을 통하여)에서 동일하게 사용이 가능하다.
성능상 로컬 라이브러리보다는 떨어지겠지만 개발생산성은 클 것이라 생각된다.
이러한 측면에서 SQLCLR은 개발자에게 이러한 것을 제공하며 제작하는 방법을 작성해본다~
1. VS2008 시작
2. 프로젝트 생성
C# > 데이터베이스 > SQL Server 프로젝트
3. SP 또는 Function을 개발 후 빌드
public partial class UserDefinedFunctions
{
[Microsoft.SqlServer.Server.SqlFunction]
public static SqlString Hello(string str)
{
// 여기에 코드를 입력합니다.
return new SqlString("Hello " + str);
}
};
4. SQL Server에서 어셈블리 등록
1) clr 권한생성
EXEC sp_configure 'clr enabled' , '1'
go
reconfigure;
2) 어셈블리 등록
CREATE ASSEMBLY 등록명 FROM '경로\dll명'
3) 개발 SP 또는 Function 등록
CREATE FUNCTION Hello
(
@str NVARCHAR(1000)
)
RETURNS NVARCHAR(1000)
AS EXTERNAL NAME SqlServerProject1.UserDefinedFunctions.Hello
참고 URL
http://msdn.microsoft.com/en-us/library/ms345135(SQL.90).aspx2010. 4. 19. 16:35
2010. 4. 19. 11:55
DI를 하기위한 spring.net에서 제공하는 object 기본 생성 방식은 아래같다.
아래와 같은 방법외에 더 있다면 있는데로 추가하도록 하겠다.
▲ dll 참조추가
- Spring.Core
▲ configSection 설정
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
</sectionGroup>
</configSections>
...
</configuration>
▲ object 설정
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections ...>
<!-- 1. 같은 config 내에서 object 설정-->
<spring>
<context>
<resource uri="config://spring/objects" />
</context>
<objects xmlns="http://www.springframework.net">
<object name="name" type="namespace.class_name, assembly_name" singleton="true/false" />
...
</objects>
<!-- 2. 포함리소스 방식 -->
<spring>
<context>
<resource uri="assembly://Spring.IocQuickStart.MovieFinder/
Spring.IocQuickStart.MovieFinder/AppContext.xml"/>
</context>
</spring>
<!-- 3. object 별로 xml 분리하여 설정 -->
<spring>
<context>
<resource uri="~/Config/CommonObjects.xml"/>
<resource uri="~/Config/Production/Services.xml"/>
<resource uri="file://%PROGRAMFILES%/myapp/ioc.config" />
</context>
</spring>
</configuration>
2번으로 할 경우는 필히 잊지말고 관련파일을 해당프로젝트(assembly)에 포함리소스로 변경해주어야 한다.
1,2,3을 혼용해서 사용이 가능한지 모르겠지만 개인적으로 3번처럼 구성하는게 좋아보인다.
▲ config에서 객체생성
- 기본객체 생성
- 프로퍼티 형식으로 객체 주입하여 생성
- constructor의 생성자에 인자로 객체생성 방법
c#
using Spring.Context;
using Spring.Context.Support;
...
IApplicationContext ctx = ContextRegistry.GetContext();
IHello hello = (IHello)ctx.GetObject("MyHello"); // config의 object의 name과 일치
string result = hello.Say("CoolDragon");
Console.WriteLine(result);
using Spring.Context.Support;
...
IApplicationContext ctx = ContextRegistry.GetContext();
IHello hello = (IHello)ctx.GetObject("MyHello"); // config의 object의 name과 일치
string result = hello.Say("CoolDragon");
Console.WriteLine(result);