대분류⚡🤖ㄱㄱㄱㄱ☕ 소분류

해결됨 (Solved) 시험토픽

발제: 시세상74 (61.106.***.***) 2026-10-11 08:52 조회 1,560 답변 12
목록으로
#1 2026-10-11 08:52:43 61.106.***.***
시험
#2 2026-10-11 08:53:39 61.106.***.***
ㅅㄷㄴㅅ
첨부 회로도/이미지
클릭하여 고해상도 원본 보기 (줌/팬/다운로드)
첨부파일 (1개)
#3 2026-10-11 10:38:13 61.106.***.***
test
#4 2026-10-11 10:38:20 61.106.***.***
ㅅㄷㄴㅅ
#5 2026-10-11 10:38:25 61.106.***.***
test
#6 2026-10-11 10:38:34 61.106.***.*** 관리자75 님에 대한 답변
관리자75 님이 2026-10-11 10:38:25에 남긴 글:
test
testset
#7 2026-10-11 10:38:39 61.106.***.*** 관리자75 님에 대한 답변
관리자75 님이 2026-10-11 10:38:34에 남긴 글:
관리자75 님이 2026-10-11 10:38:25에 남긴 글:
test
testset
ㅅㄷㄴㅅㄴㄷㅅ
#8 2026-10-11 11:26:03 61.106.***.***
test
#9 2026-10-11 11:26:06 61.106.***.***
test
#10 2026-10-11 11:26:16 61.106.***.***
1234
#11 2026-10-11 11:26:21 61.106.***.***
12345
#12 2026-10-15 20:46:15 61.106.***.***
using System;
using System.Collections.Generic;
using System.Web.Script.Serialization;
using System.Web.Services;

namespace EjpanWeb
{
public partial class Default : System.Web.UI.Page
{
// 샘플 데이터 모델
public class Category
{
public int Id { get; set; }
public string Title { get; set; }
public List<SubCategory> SubCategories { get; set; }
}

public class SubCategory
{
public int Id { get; set; }
public string Title { get; set; }
}

public class BoardItem
{
public int Id { get; set; }
public string Title { get; set; }
public string Author { get; set; }
public DateTime Date { get; set; }
}

// 샘플 카테고리 데이터 (실제 서비스에서는 DB에서 로드)
protected List<Category> SampleCategories = new List<Category>();

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// 실 서비스 통합 GNB 전환으로 더미 카테고리 주입 비활성화
ClientScript.RegisterStartupScript(this.GetType(), "initData",
"window.__INIT_CATEGORIES = [];", true);
}
}

private void InitSampleData()
{
SampleCategories = new List<Category>();
}

// AJAX 엔드포인트: 서브카테고리 반환 (JSON)
[WebMethod]
public static string GetSubCategories(int categoryId)
{
// 실제 서비스: DB 조회
var categories = new Default().GetCategoriesForAjax();
var cat = categories.Find(c => c.Id == categoryId);
var serializer = new JavaScriptSerializer();
//return serializer.Serialize(cat?.SubCategories ?? new List<SubCategory>());
List<SubCategory> subs;

if (cat != null && cat.SubCategories != null)
{
subs = cat.SubCategories;
}
else
{
subs = new List<SubCategory>();
}
return serializer.Serialize(subs);

}

// AJAX 엔드포인트: 게시판 리스트 반환 (JSON)
[WebMethod]
public static string GetBoardList(int subCategoryId)
{
// 샘플 게시판 데이터 생성 (실제 서비스: DB 조회)
var boards = new List<BoardItem>();
for (int i = 1; i <= 12; i++)
{
boards.Add(new BoardItem
{
Id = subCategoryId * 100 + i,
Title = string.Format("게시물 {0} (서브 {1})", i, subCategoryId),

Author = "관리자",
Date = DateTime.Now.AddDays(-i)
});
}
var serializer = new JavaScriptSerializer();
return serializer.Serialize(boards);
}

// 인스턴스용 카테고리 반환 (내부 사용)
private List<Category> GetCategoriesForAjax()
{
InitSampleData();
return SampleCategories;
}
}
}
#13 2026-10-15 20:47:10 채택된 해결책 (Accepted Solution) 61.106.***.***
C++
using System;
using System.Collections.Generic;
using System.Web.Script.Serialization;
using System.Web.Services;

namespace EjpanWeb
{
    public partial class Default : System.Web.UI.Page
    {
        // 샘플 데이터 모델
        public class Category
        {
            public int Id { get; set; }
            public string Title { get; set; }
            public List<SubCategory> SubCategories { get; set; }
        }

        public class SubCategory
        {
            public int Id { get; set; }
            public string Title { get; set; }
        }

        public class BoardItem
        {
            public int Id { get; set; }
            public string Title { get; set; }
            public string Author { get; set; }
            public DateTime Date { get; set; }
        }

        // 샘플 카테고리 데이터 (실제 서비스에서는 DB에서 로드)
        protected List<Category> SampleCategories = new List<Category>();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // 실 서비스 통합 GNB 전환으로 더미 카테고리 주입 비활성화
                ClientScript.RegisterStartupScript(this.GetType(), "initData",
                    "window.__INIT_CATEGORIES = [];", true);
            }
        }

        private void InitSampleData()
        {
            SampleCategories = new List<Category>();
        }

        // AJAX 엔드포인트: 서브카테고리 반환 (JSON)
        [WebMethod]
        public static string GetSubCategories(int categoryId)
        {
            // 실제 서비스: DB 조회
            var categories = new Default().GetCategoriesForAjax();
            var cat = categories.Find(c => c.Id == categoryId);
            var serializer = new JavaScriptSerializer();
            //return serializer.Serialize(cat?.SubCategories ?? new List<SubCategory>());
						List<SubCategory> subs;

						if (cat != null && cat.SubCategories != null)
						{
								subs = cat.SubCategories;
						}
						else
						{
								subs = new List<SubCategory>();
						}
						return serializer.Serialize(subs);

        }

        // AJAX 엔드포인트: 게시판 리스트 반환 (JSON)
        [WebMethod]
        public static string GetBoardList(int subCategoryId)
        {
            // 샘플 게시판 데이터 생성 (실제 서비스: DB 조회)
            var boards = new List<BoardItem>();
            for (int i = 1; i <= 12; i++)
            {
                boards.Add(new BoardItem
                {
                    Id = subCategoryId * 100 + i,
                    Title = string.Format("게시물 {0} (서브 {1})", i, subCategoryId),
										
                    Author = "관리자",
                    Date = DateTime.Now.AddDays(-i)
                });
            }
            var serializer = new JavaScriptSerializer();
            return serializer.Serialize(boards);
        }

        // 인스턴스용 카테고리 반환 (내부 사용)
        private List<Category> GetCategoriesForAjax()
        {
            InitSampleData();
            return SampleCategories;
        }
    }
}

답변 작성 및 실시간 동기화는 로그인 후 이용 가능합니다

비회원은 게시글 열람만 가능하며, 답변 작성 및 초경량 실시간 리플 스트리밍은 회원 로그인 후 이용하실 수 있습니다.