ASP .NET :: CS <--> Aspx 변수 저장 문의

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="webform._Default" %>

<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">

    <div class="row">
        <% if(!hist_Yn) { %>
            <div>None</div>
        <% } %>

        <% foreach(var key in ht.Keys) { %>
            <div><%=ht[key]%></div>
        <% } %>
    </div>

</asp:Content>
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace webform
{
    public partial class _Default : Page
    {
        public bool hist_Yn = false;
        public Hashtable ht = new Hashtable();
        protected void Page_Load(object sender, EventArgs e)
        {
            ht.Add("aaa", "111");
            ht.Add("bbb", "222");

            if (ht.Count > 0)
            {
                hist_Yn = true;
            }
        }
    }
}

이런걸 말씀하시나요? 중간에 else가 빠졌는데 foreach앞에 넣으시면 될듯합니다.

4개의 좋아요