블로그 이미지
다비도프

만나고, 고백하고, 가슴 떨리고, 설레이고, 웃고, 사랑하고, 키스하고, 함께하고..

Rss feed Tistory
WEB/ASP.NET With C# 2007. 3. 17. 05:03

VS.NET 2003 - 인텔리센스 기능이 안됩니다!!



그냥 Tip!! Devpia에서 주워왔어욤~

출처 : http://www.devpia.com/MAEUL/Contents/Detail.aspx?BoardID=7&MAEULNO=5&no=68319&ref=68318&page=1#Contents68319
,
WEB/ASP.NET With C# 2007. 3. 16. 19:10

이런 실수는 조심하자...

이번 프로젝트 중에 나온 논리적 오류다.


물론 컴파일시 오류는 발생하지 않는다. 하지만 퍼포먼스 상에서 심각한 차이를 보인다.
문제가 되는 부분은 MemberBiz View = new MemberBiz(BlogID); 이거다.

For 루프를 돌면서 curRow의 수만큼 반복적으로 DB에 Connection을 요청하기 때문에
페이지 로딩은 심각하게 느려진다.

이런 부분에서의 오류는 치명적이다..

,
WEB/ASP.NET With C# 2007. 3. 14. 12:12

BasePage

개발방법

프로젝트내 모든 페이지의 기본이 되는 BasePage를 만든 후
프로젝트의 페이지 작성시 BasePage를 상속받는다.

BasePage의 함수는 모든 페이지에 영향을 끼치며 모든페이지에서 사용할 수 있으므로
전체 페이지에서 활용할 수 있는 함수를 작성한다. (ex : View History, 사용자 인증, 에러처리 등등)

BasePage를 작성하여 사용할 경우에는 Init의 순서가 변경되어져야 한다.
다른 Control들이 로딩되기전에 BasePage의 설정값이 로딩되어야 하기 때문이다.

,
WEB/ASP.NET With C# 2007. 3. 14. 12:02

Control : PlaceHolder

<aspx>
....
<asp:PlaceHolder ID="PlaceHolder1" runat="server" ></asp:PlaceHolder>
....

이렇게 자리를 잡아준다..


<cs>

...
PG.Temp.Sample.ucSample ucSample1 = (PG.Temp.Sample.ucSample) LoadControl(("include/ucSample.ascx");
ucSample1.[public 속성값] = 설정;
PlaceHolder1.Controls.Add(ucSample1);
...

요렇게 하믄 aspx안의 PlaceHolder가 잡아놓은 Place에 ucSample형 객체인 ucSample1이 들어간다.. 워~~  'ㅁ')
UserControl뿐만 아니라 니가 추가하고자 하는 모든 Control이 해당될 수 있다고 하니 엄청난거다..


Understand PlaceHolder

Understand PlaceHolder


,
WEB/ASP.NET With C# 2007. 3. 14. 11:55

RealLength

string의 길이를 구한다. &lt; &gt; 를 '<', '>'로 계산해서..
귀찮아서 만들었는데 결국 쓰지는 않는...OTL

public int RealLength(string strRetString)
{
 // '<' 의 개수를 센다.
 int i =0;
 int cntCharLT = 0;

 while(i < strRetString.Length)
 {
  i = strRetString.IndexOf("&lt;", i);
  if(i != -1 && i < strRetString.Length)
  {
   cntCharLT = cntCharLT + 1;  
   i= i+4;    
}

  if(i == -1)
   break;
 }

 // '>'의 개수를 센다.
 int j =0;
 int cntCharGT = 0;

 while(j < strRetString.Length)
 {
  j = strRetString.IndexOf("&gt;", j);

  if(j != -1 && j < strRetString.Length)
  {
   cntCharGT = cntCharGT + 1;
   j= j+4;
  }

  if(j == -1)
   break;
 }

 int realLength =  (strRetString.Length - cntCharGT*3- cntCharLT*3);

 return realLength;
}

,
WEB/ASP.NET With C# 2007. 3. 13. 16:13

HttpContext.Current.Cache의 사용..

   //--> 캐쉬에서 가져오기 : 저장되어져 있는 cache가 있다면 ds에 그값을 저장한다.  
   ds = (DataSet) HttpContext.Current.Cache["cacheXXX"];

   // 만약 저장된 cache가 없다면..
    if (ds==null)
    {
         // DB에서 DataSet을 받는다.
        ds =  <-- DataSet을 실제로 받아서 넣는것임......!!!!!

        if (ds.Tables[0].Rows.Count > 0)
        {
            // DB에 데이터가 있다면 받아온 데이터를 캐쉬에 Insert!!
            HttpContext.Current.Cache.Insert("cacheXXX", ds, null, DateTime.Now.AddMinutes(10), System.Web.Caching.Cache.NoSlidingExpiration);
        }
        else
        {
            // 받아온 데이터가 없다면..
            HttpContext.Current.Cache.Remove("cacheXXX");
            //--> 데이터가 없다는 얘긴데, 말도 안되므로 캐쉬를 일단 제거해줌
            // (빈캐쉬가 오랫동안 남지 않도록)
        }
    }


    컨트롤.DataSource = ds;
    컨트롤.DataBind();
,
WEB/ASP.NET With C# 2007. 3. 13. 16:05

3Tier..?

3Tier로 개발할때 중요한 건
미리 요구사항 분석 완료, DB설계, 프로시져 제작,
그다음에 데이터 계층 설계, 그 다음에 비지니스 계층 설계, 프레젠테이션은..??
그리고 데이터 계층 코딩, 비지니스 코딩, 프레젠테이션 코딩 순서로.. 가는 거 같다..
결국 DB랑 똑같은 걸..
3 Tier, 3 Layer 헷갈리다가 찾은 문서..
물리적인 분리냐, 논리적인 분리냐에 따라 Tier인지 Layer인지 구분한다는 거!!
혼용하지 말 것!!

아래는 참고글 : http://vishwamohan.blogspot.com/2006/10/understanding-3-tier-vs-3-layer.html

Understanding 3-Tier vs. 3-Layer Architecture

The terms tier and layer are frequently used interchangeably, but actually there is a difference between them: Tiers indicate a physical separation of components, which may mean different assemblies such as DLL, EXE etc on the same server or multiple servers; but layers refers to a logical separation of components, such as having distinct namespaces and classes for the Database Access Layer (DAL), Business Logic Layer (BLL) and User Interface Layer (UIL). Therefore, tier is about physical separation and units of deployment, and layers are about logical separation and units of design.

Creating a multi tier project design is more suitable and advisable to mid to large-size projects, whereas a good multi-layered design is suitable for small to mid-size projects.

Let’s understand this difference more closely with my earlier posts on “Developing 3-Tier Application in .NET 2.0”. In reality this example is 3-layer architecture because all the layers are logically separated but stay in one code. Following are the namespaces of each layer

1. eBizzTech.Examples.Web.DAL
2. eBizzTech.Examples.Web.BLL
3. eBizzTech.Examples.Web.UIL


The final DLL contains all the above layers: eBizzTech.Examples.Web.dll

Now, let’s think how to build the same project in true 3-tier architecture. For simple understanding, each layer will be moved to a separate project and thus creating following three dlls. These dlls can stay on the same machine or different servers.

1. eBizzTech.Examples.Web.DAL.dll
2. eBizzTech.Examples.Web.BLL.dll
3. eBizzTech.Examples.Web.UIL.dll


But, by just moving the code of each layer into a separate project will not work, because first and foremost issue is: each layer depends on other layer, so you can not compile one project without other one and here you are in catch 22 situation.

So you will require changes into current design. Also, if you are not planning to keep all the layers in the same folder of your application, then another big issue- how to refer and communicate with each layer’s object. Here is some approach you can take for each layer to convert into a tier model.

  • Literally, create a separate project for each layer.
  • For Database Access Layer and Business Logic Layer ASP.NET Web Services or .NET Remoting can be used. If you can use .NET 3.0 Windows Communication Foundation (WCF) Services, that will be great, they seem to me like Web Services but more powerful, secure and flexible than Web Services.
  • User Interface Layer will stay as ASP.NET Web Site but some changes will be required for invoking or calling Business Objects. However, existing BLL and DAL layers will be removed from current project.
  • Additionally, I will recommend using Microsoft Enterprise Library - Application Blocks for .NET 2.0. This library can help you to build a robust application, it provides solutions to common development challenges such as data access, logging and user interface etc. You can find more information at http://msdn.microsoft.com/practices
  • By using (Web) Services, you will move one step towards Service Oriented Architecture (SOA), which is becoming more popular now in enterprise application development.
You must be wondering why did I use the word 3-Tier instead of 3-layer?

First of all most of the time people are searching on key words like 3-Tier rather 3-Layer. Word 3-tier architecture is most frequently used but heavily misused in IT industry. So it is easier to bring people to the information they are looking for and then educate them as what exactly it means.

Needless to say that it was easier for me to take a simple example for 3- layer architecture design and explain each layer step by step. Developing a true multi tier approach may look like over killing of the sample project. I may write one sometime in future:).
,
WEB/ASP.NET With C# 2007. 3. 9. 15:56

[개발] AJAX - Rolling List

요번 프로젝트때 만든 롤링리스트...
10초마다 ajax함수를 호출해서...
함수에 요청하는 건데.. 부하가 많이 걸려서 OTL

[aspx]

<UL id=RollListSubList>
<asp:Literal id=ltrMainRssList EnableViewState="False" Runat="server"></asp:Literal>
</UL>
<script language="javascript" type="text/javascript">
   function ReloadRollList(){Ajax.PG.ucRollListNetSub.reloadList(Reload_CallBack);}
   function Reload_CallBack(res){
        if(res != null){
              var divRss = document.getElementById('RollListSubList'); divRss.innerHTML = res.value;}}
   setInterval("ReloadRollList();", 10000);
</script>

[cs]

[AjaxPro.AjaxMethod]
  public string reloadList()
  {
   int temp = 0;
   DataSet ds = RollListNetBiz.GetListAdminRecommand(1,30, out temp);

   if(ds != null)
   {
    DataTable dt = Utility.RollingData(ds.Tables[0], 10);   
    string HTML = string.Empty;
    Random random = new Random();
   
    int boldNum1 = random.Next(0, 4);
    int boldNum2 = random.Next(5, 9);

    for(int i = dt.Rows.Count -1 ; i >= 0 ; i--)
    {
     int RollListID = (int) dt.Rows[i]["RollListID"];
     string Title = dt.Rows[i]["Title"].ToString();
     string Content = dt.Rows[i]["Content"].ToString();
     string Link = dt.Rows[i]["ContentUrl"].ToString();
     string MasterName = dt.Rows[i]["MasterName"].ToString();
     DateTime Date = (DateTime) (dt.Rows[i]["PubDate"]);

     string MasterLink = "./RollListNetMaster.aspx?MasterID=" + RollListID.ToString();

     Title = Utility.RemoveHTML(Title);
     Title = Utility.RemoveHTMLTag(Title);
     Title = Utility.GetTitles(Title, 12);

     if(i == boldNum1 || i == boldNum2)
     {
      Title = Utility.GetTitles(Title, 10);
      HTML  += "<li class='bold'><a href='" + Link + "' target='RollListViewer'>" + Title + "</a></li>";
     }
     else
     {
      Title = Utility.GetTitles(Title, 12);
      HTML  += "<li><a href='" + Link + "' target='RollListViewer'>" + Title + "</a></li>";
     }
    }
    return HTML;
   }
   else
    return null;
  }

,
WEB/ASP.NET With C# 2007. 3. 9. 13:31

[개발] 올블로그 - 아이디 체크

간단하게 아이디체크 구현해보자..
정말 간단.. -ㅁ-;;



 올블로그에서 회원가입시 포스트백 없이 아이디 체크되는 걸.. 보고..
혹해서 만들어봤다..


[aspx]
<script type="text/javascript" src="./lib/prototype/prototype.js"></script>
 <script>
      function AjaxIDCheck(param)
      {
          PG.AjaxBoard.IDCheck.IDChecking(param, IDCheck_CallBack);
      }

      function IDCheck_CallBack(res)
      {
          var check_value = res.value;
   
          if(check_value)
              lblText.innerHTML = "사용하실 수 있는 ID 입니다.";    
          else
              lblText.innerHTML = "이미 등록된 ID 입니다.";    
      }
   
      function IDCheck()
      {
          var param = $('txtID').value;
   
          if(param.trim() == "")
              lblText.innerHTML = "ID를 입력해주세요.";    
          else
              AjaxIDCheck(param);
      }
  </script>
   ...
   <input type="text" ID="txtID" Width="200px" onkeyup="IDCheck()"/>
   <label id="lblText"></label>
   ...

   
[cs]
   private void Page_Load(object sender, System.EventArgs e)
  {
      AjaxPro.Utility.RegisterTypeForAjax(typeof(IDCheck));
  }

   [AjaxPro.AjaxMethod]
   public bool IDChecking(string strID)
   {
      bool check_value = false;

      // DB단 처리
      ...

      return check_value;
   }


생각보다 무지 간단하구나..=ㅁ=;;
올블로그랑 똑같이 하려면 onkeyup 이벤트를 onblur 이벤트로 바꿔주면 된다..

,
TOTAL TODAY