WebService 내 DataTable 이용하여 로직 구현 후, JQuery로 데이터 가져오는 방법
페이지 코드
 

JQuery Demo Page



이름 나이
WebService 코드
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Script.Serialization;
using System.Web.Script.Services;
using System.Web.Services;

namespace TEST.WS
{
    /// 
    /// UserInfoWS의 요약 설명입니다.
    /// 
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // ASP.NET AJAX를 사용하여 스크립트에서 이 웹 서비스를 호출하려면 다음 줄의 주석 처리를 제거합니다. 
    [System.Web.Script.Services.ScriptService]
    public class UserInfoWS : System.Web.Services.WebService
    {
        [WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public string GetUserInfo(string id)
        {
            DataTable dtUserInfo = new DataTable("UserInfo");

            dtUserInfo.Columns.Add("FirstName", typeof(string));
            dtUserInfo.Columns.Add("LastName", typeof(string));
            dtUserInfo.Columns.Add("Age", typeof(string));
            dtUserInfo.Columns.Add("ID", typeof(string));

            DataRow drUserInfo = dtUserInfo.NewRow();
            drUserInfo["FirstName"] = "길동";
            drUserInfo["LastName"] = "홍";
            drUserInfo["Age"] = "29";
            drUserInfo["ID"] = id;
            dtUserInfo.Rows.Add(drUserInfo);

            JavaScriptSerializer serializer = new JavaScriptSerializer();
            List userInfos = new List();
            UserInfo userInfo = null;
            foreach (DataRow dr in dtUserInfo.Rows)
            {
                userInfo = new UserInfo();
                userInfo.FirstName = dr["FirstName"].ToString();
                userInfo.LastName = dr["LastName"].ToString();
                userInfo.Age = dr["Age"].ToString();
                userInfo.ID = dr["ID"].ToString();

                userInfos.Add(userInfo);
            }

            return serializer.Serialize(userInfos);
        }

        public class UserInfo
        {
            public string FirstName { get; set; }
            public string LastName { get; set; }
            public string Age { get; set; }
            public string ID { get; set; }
        }
    }
}
여기서 주의 할 점..

  1. WebMethod 내 JavaScriptSerializer 클래스를 통하여 DataTable 개체를 JSON 문자열로 변환하여 String으로 리턴하여야 함.
    -  
      Object 타입의 개체를 넘겨주어야 하므로, 위 소스에서는 별도의 클래스를 정의하여 개체로 넘김.
  2. 위 JSON 문자열로 처리 했다고 해서.. JQuery ajax 내에서 return.d 로만 처리하면 속성값을 찾지 못함.

    success: function (result) {
          data = $.parseJSON(result.d);
          
    $.each(data, function (i, item) {
                   //위처럼 선언 안하고, item.FirstName 속성 값을 가져오지 못함.
           }
    }; 

This post covers, how to hide the button from the Server Ribbon from SharePoint 2010,

We are going to use the Feature files to hide the SharePoint 2010. First we will create a Feature file and then we’ll create a element file.

Feature.xml

 
 
 
 
 

Elements.xml

 
 
 
 

There was a HideCustomAction element used to hide / remove the button from Server Ribbon Control. If we want to remove particular Button / Group / Tab we have to specify the respective Button’s Location ID on HideActionId attribute.

HideActionId – Specifies the Location ID of the custom action to hide

Location – Specifies the Parent location Id of the custom action to hide.

By using HideCustomAction, we can hide / remove the Button, Group, Tab.

Example

For example I have provided a element.xml for hiding the Upload Multiple button from the Document Library.

Elements.xml

 
 
 
 

The above xml file, used to remove the Upload Multiple Documents from the Server ribbon on Document Libraries.

I have added the code in codplex, http://iotapsp.codeplex.com/


9.1 Form 플러그인

9.1.1 폼 컨트롤 값 가져오기

  • 컨트롤 값 가져오기
    • fieldValue() - 확장 집합 내의 모든 전송 가능한 폼 컨트롤이 가진 값의 배열을 변환한다.
    • val() - 확장 집합내의 첫번째 전송 가능 폼 컨트롤 엘리먼트 값을 반환한다.
    • $(#testForm *').fieldValue()
    • $(#testForm *').fieldValue(false) - 전송 불가능한 컨트롤 제외하지 않음
  • 컨트롤 값 직렬화하기
    • 인코딩된 쿼리문자열로 만든다
    • formSerialize() - 확장집합내의 폼을 받아서 폼에 있는 전송 가능한 자식 컨트롤의 값을 모두 직렬화
    • fieldSerialize() - 확장집합내의 모든 컨트롤을 직렬화
    • $('#testForm').formSerialize()

9.1.2 폼 컨트롤의 값 지우고 재설정하기

  • clearForm() - 텍스트, 패스워드, 텍스트 영역 지운다. <select>엘리먼트 선택 취소, 체크박스 라디오버튼 해제
  • resetForm() - HTML 마크업 지정값으로 되돌림 (reset() 메서드 호출)

9.1.3 Ajax를 사용하여 폼 값 전송하기

  • Form플러그인의 formSerialize()메서드와 코어 Ajax함수를 조합하면 된다.
  • Form플러그인의 ajaxSubmit()커멘드를 쓰면 Ajax를 통한 전체 폼 전송이 더 쉽다.
  • $('#targetForm').ajaxSubmit(); - 폼 전송
  • $('#targetForm').ajaxSubmit(function(response){

      /* response와 함께 어떠한 작업 처리 */

});

  • ajaxForm() - 일반적인 의미의 이벤트로 발생한 폼 전송을 막고 요청을 모방하는 Ajax요청을 전송한다.
  • ajaxFormUnbind() - 폼이 일반적인 방식으로 전송될 수 있도록 화장 집합내의 폼에 전용된 기능을 제거한다.

9.1.4 파일 전송하기

  • Form플러그인은 file타입 입력 엘리먼트에 명시된 파일을 업로드하는 폼을 알아서 식별하고 처리한다.

9.2 Dimensions 플러그인

9.2.1 width height 메서드 확장하기

9.2.2 스크롤 크기 얻어내기

9.2.3 오프셋과 위치

9.3 Live Query 플러그인

  • 셀렉터와 일치하는 엘리먼트에 이벤트 핸들러를 할당한다.
  • 어떠한 엘리먼트가 셀렉터와 일치할 때 실행될 함수를 호출한다.
  • 더는 어떠한 엘리먼트 셀렉터와 일치하지 않을 때 실행될 함수를 호출한다.

9.3.1 이벤트 핸들러 미리 할당하기

9.3.2 일치리스너와 불일치 리스너 정의하기

9.3.3 Live Query를 강제로 적용하기

9.3.4 Live Query 리스너 제거하기

9.4 UI 플러그인 소개

9.4.1 마우스 상호작용

  • draggable(options)
  • ui.mouse.js, ui.draggable.js를 포함 해야 한다.
  • ui.draggable.ext.js 확장 옵션을 위해서 포함해야 함
  • $('#testSubject').draggable({});

9.4.2 위짓과 시각효과

+ Recent posts