사용할 수있는 마법사 컨트롤이 있다는 것을 알고 있습니다. 그러나 내가 원했던 것은 너무 단순해서 어디서부터 시작했는지 알 수 없습니다. 사용자가 이름과 히트를 다음에 넣을 때 나는 달력 컨트롤을 시작 날짜로 선택할 수있게하려고한다. 시작일을 초록색으로 표시 할 수 있습니다. 계속 버튼을 누를 때까지 선택하길 바래. 문제 1은 그들이 날짜없이 다음에 칠 수 있다는 것입니다. 나는 그것을 잡고 싶다. 두 번째 문제는 다음에 타격을주기 전에 여러 번 다시 선택할 수 있다는 것입니다. 나는 그들이 그 일을 할 수 있기를 바랍니다. 그들이 다음에 히트를하면, 나는 그들이 다음에 칠 때까지 계속 날짜를 선택하고 끝낼 수 있기를 바란다. 그 다음에 나는 그들에게 그들의 코즈를 확인하길 바란다. 나는 논리가 그렇게 단순하지 않다는 것을 짐작한다 ... 나가 쓴 부호는 아주 나쁘다. StartDateStartPart 및 EndDateStartPart 그냥 정신 횡설수설되기 때문에 :(. 심지어 적절한 수정이 내 머리를 다치게. 내가 분명히 다시 생각하고 처음부터이 작업을 다시해야 할 것입니다.ASP.NET 마법사를 디자인하는 좋은 방법이 있습니까?
<script runat="server" enableviewstate="True">
DateTime begin;
DateTime end;
int iSelectedStart = 0;
int iSelectedEnd = 0;
int iPutName = 0;
protected void Button1_Click(object sender, EventArgs e)
{
if (iPutName == 0)
{
Label1.Text = TextBox1.Text + " you will be slecting your start and end dates.";
LabelInstructions1.Text = "Please select a begin date and hit next";
Calendar1.SelectionMode = System.Web.UI.WebControls.CalendarSelectionMode.Day;
iPutName = 1;
ViewState["iPutName"] = 1;
ViewState["Label1_Text"] = Label1.Text;
ViewState["LabelInstructions1_Text"] = LabelInstructions1.Text;
ViewState["Calendar1_SelectionMode"] = Calendar1.SelectionMode;
}
else
{
if (iSelectedStart <= 0)
{
LabelInstructions1.Text = "You have not selected a start date please do so.";
}
else if (iSelectedStart < 99)
{
iSelectedStart = 99;
Label1.Text = TextBox1.Text + " you will be slecting your start and end dates.";
LabelInstructions1.Text = "Please select an end date and hit confirm";
ViewState["begin"] = begin;
ViewState["iSelectedStart"] = iSelectedStart;
}
else
{
if (iSelectedEnd = 0)
{
LabelInstructions1.Text = "You have not selected a start date please do so.";
}
}
}
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
if (iSelectedStart < 99)
{
iSelectedStart++;
begin = Calendar1.SelectedDate;
ViewState["iSelectedStart"] = iSelectedStart;
ViewState["begin"] = begin;
}
else
{
if (begin == Calendar1.SelectedDate)
{
LabelInstructions1.Text = "Error you cannot select the same start and end date";
LabelInstructions1.ForeColor = System.Drawing.Color.Red;
}
else
{
end = Calendar1.SelectedDate;
iSelectedEnd = 0;
ViewState["end"] = end;
}
}
}
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
if (e.Day.Date == begin)
{
e.Cell.BackColor = System.Drawing.Color.Green;
}
if (e.Day.Date == end)
{
e.Cell.BackColor = System.Drawing.Color.Red;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (ViewState["iPutName"] != null)
iPutName = (int)ViewState["iPutName"];
if (ViewState["Label1_Text"] != null)
Label1.Text = ViewState["Label1_Text"].ToString();
if (ViewState["LabelInstructions1_Text"] != null)
LabelInstructions1.Text = ViewState["LabelInstructions1_Text"].ToString();
if (ViewState["Calendar1_SelectionMode"] != null)
Calendar1.SelectionMode = (CalendarSelectionMode) ViewState["Calendar1_SelectionMode"];
if (ViewState["begin"] != null)
begin = (DateTime)ViewState["begin"];
if (ViewState["end"] != null)
end = (DateTime)ViewState["end"];
}
asp.net 태그를 추가하십시오 : – JoshJordan
일부는 조언을 주셔서 감사합니다! – ojblass
나만의 답변으로 마무리해야합니까? – ojblass