HttpFileCollection 을 사용한 다중 파일 업로드

.Net 2009. 5. 21. 15:57 posted by 무명시인
사용자 삽입 이미지

이렇게 여러게의 파일컴포넌트가 있다면;;

머 각기 파일 존대 여부를 체크하여 파일을 업로드 하여도 상관은 없다..

하지만..

이왕이면 코드를 줄여보자..

이렇게

 HttpFileCollection file = Request.Files;

        for (int i = 0; i < file.Count; i++)
        {
            if (file[i].ContentLength > 0)
            {
                HttpPostedFile postedFile = file[i];
                string strPath = String.Format("{0}\\{1}", Server.MapPath("~/Files"), System.IO.Path.GetFileName(postedFile.FileName));                
                postedFile.SaveAs(strPath);
            }            
         
}
사용자 삽입 이미지


이런 코드를 사용하여 유저컨트롤이나 사용자 정의 컨트롤로 멀티 업로드 컴포넌트를 만들어 사용해도 무관하겠다.

Asp.Net Hashtable 의 이해

.Net 2009. 5. 20. 09:53 posted by 무명시인

//[1]Hashtable 개체 Hashtable ht1 = new Hashtable(); Hashtable ht2 = new Hashtable(); //[2]할당 ht1.Add("a", "aa"); ht1.Add("b", "bb"); ht1.Add("c", "cc"); ht1.Add("d", "dd"); ht1.Add("e", "ee"); ht2.Add(0, "0"); ht2.Add(1, "1"); ht2.Add(2, "2"); //[3]DictionaryEntry 를 사용 foreach (DictionaryEntry de in ht1) { Response.Write(String.Format("key : {0}, value : {1}
", de.Key, de.Value)); } Response.Write("
"); //[4]ICollection 를 사용 ; 값만 ICollection ic = ht1.Values; foreach (string str in ic) { Response.Write(String.Format("values : {0}
", str)); } Response.Write("
"); //[5]ICollection 를 사용 ; 키만 ICollection ic2 = ht1.Keys; foreach (string str2 in ic2) { Response.Write(String.Format("keys : {0}
", str2)); } Response.Write("
"); //[6]인덱스 for (int i = 0; i < ht2.Count; i++) { Response.Write(String.Format("index : {0}, value: {1}", i.ToString(), ht2[i])); Response.Write("
"); } Response.Write("
"); //[7]IEnumerator 사용 ; 값만 IEnumerator ie1 = ht1.Values.GetEnumerator(); while (ie1.MoveNext()) { Response.Write(String.Format("value : {0}
", ie1.Current.ToString())); } Response.Write("
"); //[8]IEnumerator 사용 ; 키만 IEnumerator ie2 = ht1.Keys.GetEnumerator(); while (ie2.MoveNext()) { Response.Write(String.Format("key : {0}
", ie2.Current.ToString())); }

CodeHighLight - SyntaxHighlighter 2.0 사용하기

Js & Css 2009. 5. 18. 16:36 posted by 무명시인




http://code.google.com/p/syntaxhighlighter/

첨부파일을 다운받는다..

13개의  .js 파일과

1개의 .css 와

1개의 .swf 파일이 있다.


사용자 삽입 이미지

각각 인클루드를 하고..

사용법은 쉽다..

       <pre name="code" class="c-sharp">
        using System;
        using System.Collections.Generic;
        using System.Linq;
        using System.Web;
        using System.Web.UI;
        using System.Web.UI.WebControls;

        public partial class CodeHighLight_Test : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {

            }
        }

        </pre>
        <hr />
        <pre name="code" class="c-sharp:collapse">
        using System;
        using System.Collections.Generic;
        using System.Linq;
        using System.Web;
        using System.Web.UI;
        using System.Web.UI.WebControls;

        public partial class CodeHighLight_Test : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {

            }
        }

        </pre>
        <hr />
        <textarea name="code" class="c#" cols="60" rows="10">
        using System;
        using System.Collections.Generic;
        using System.Linq;
        using System.Web;
        using System.Web.UI;
        using System.Web.UI.WebControls;

        public partial class CodeHighLight_Test : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {

            }
        }

        </textarea>

사용자 삽입 이미지

컨태이너 역활을 할 html 태그에 class 를 해당 언어명으로 주면된다.

width 는 태이블로 감사서 주어야 한다 ..

웹에디터나 이런걸로 얼마든지 사용이 가능할것 같다.

asp.net webpart 개요

.Net 2009. 5. 18. 09:45 posted by 무명시인
사용자 삽입 이미지

역기 MSDN 에는 모든게 다 있다.

http://msdn.microsoft.com/ko-kr/library/e0s9t4ck.aspx

ascx 와 ascx 간의 값전달

.Net 2009. 5. 14. 11:05 posted by 무명시인
사용자 삽입 이미지

aspx 페이지에 유저 컨트롤의 2개 올려 놓고..

사용자 삽입 이미지
ascx 에 컨트롤들을 public 한 속성으로 지정하고..

(1) 이벤트가 없는 버튼
(2) 텍스트 박스
(3) 리터랄

사용자 삽입 이미지
(1) ascx 의 버튼 이벤트 등록..델리게이트 개념
(2)(3) 이벤트 내용

사용자 삽입 이미지
ascx1 의 텍스트 입력값이 ascx2의 리터랄에 입력됨

자바스크립트로 .net framework 버젼확인

OpenApi 2009. 5. 14. 08:56 posted by 무명시인

navigator.userAgent

사용자 삽입 이미지


NET CLR 버젼..

.net framework 버전 확인

.Net 2009. 5. 11. 14:49 posted by 무명시인
Version nowVer = Request.Browser.ClrVersion;

Version requireVer = new Version(2, 0, 50727);
        
if (nowVer.Major == 0)
{
	Response.Write("닷넷 프레임워크 없음");
}
else
{
	if (nowVer <= requireVer)
        {
        	Response.Write("1.1.4322 보다 적음");
        }

        Response.Write(nowVer.ToString() + "
" + requireVer.ToString()); }

페이지에서 지정된 위치로 이동

Js & Css 2009. 5. 8. 17:55 posted by 무명시인
    1<a name="1"></a><br /><br /><br />
    2<a name="2"></a><br /><br /><br />
    3<a name="3"></a><br /><br /><br />
    4<a name="4"></a><br /><br /><br />
    5<a name="5"></a><br /><br /><br />   
    <a href="#1">1</a>&nbsp;
    <a href="#2">2</a>&nbsp;
    <a href="#3">3</a>&nbsp;
    <a href="#4">4</a>&nbsp;
    <a href="#5">5</a>&nbsp;



HTML 이 가장 어려웠어요..

Ms-Sql sample database download

About DataBase 2009. 5. 7. 14:34 posted by 무명시인
http://msdn.microsoft.com/ko-kr/library/8b6y4c7s.aspx

ms-sql 2000 버젼이긴 하지만..

mdf 파일을 임포트 하면 된다.

http://msftdbprodsamples.codeplex.com/

asp.net 쿠키(cookie) 관련

.Net 2009. 5. 6. 16:45 posted by 무명시인