我创建了时间段....
它基本上是Bootstrap代码....,我想在.net中为我的项目目的执行....
我在我的项目中使用了一些DropDownLists ......他们的事件没有工作.....
执行后没有显示任何内容......
我的代码如下....
<body>
<form id="Form1" runat="server">
<!-- start: Header -->
<div class="navbar">
<div class="navbar-inner">
</div>
</div>
<!-- start: Header -->
<div class="container-fluid-full">
<div class="row-fluid">
<div id="content" class="span10">
<div class="row-fluid">
<div class="box span12">
<div class="box-header">
<h2><i class="icon-bookmark"></i>Create Event</h2>
</div>
<div class="box-content">
<div id="MyWizard" class="wizard">
<ul class="steps">
<li data-target="#step1" class="active"><span class="badge badge-info">1</span></li>
<li data-target="#step2"><span class="badge">2</span></li>
<li data-target="#step3"><span class="badge">3</span></li>
<li data-target="#step4"><span class="badge">4</span></li>
<li data-target="#step5"><span class="badge">5</span></li>
</ul>
<div class="actions">
<button type="button" class="btn btn-prev"><i class="icon-arrow-left"></i>Prev</button>
<button type="button" class="btn btn-success btn-next" data-last="Finish">Next<i class="icon-arrow-right"></i></button>
</div>
</div>
<div class="step-content">
<div class="step-pane active" id="step1" runat="server">
<div class="control-group ">
<div class="controls">
<h1>Create a new event<asp:TextBox ID="EventName_TB" runat="server" CssClass="control-label"></asp:TextBox>
starting on
<asp:TextBox ID="StartDate_TB" runat="server" Style="color: #727272 !important; font-size: 24px; font-weight: 100;" CssClass="span2 input-xlarge datepicker" ></asp:TextBox>
for
<asp:DropDownList ID="EventDuration_DDL" runat="server" Style="color: #727272 !important; font-size: 24px; font-weight: 100;" CssClass="span1" OnSelectedIndexChanged="EventDuration_DDL_SelectedIndexChanged">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
<asp:ListItem>6</asp:ListItem>
<asp:ListItem>7</asp:ListItem>
</asp:DropDownList>
days. </h1>
</div>
</div>
</div>
<div class="step-pane" id="step2" runat="server" visible="false">
<div class="control-group ">
<h1>Matching making will be held on the following days:
<br />
<br />
</h1>
<div class="row-fluid">
<span class="h1size">
<asp:Label ID="Label1" runat="server" Visible="false"></asp:Label>
</span>
<div class="make-switch pull-right" data-on="info">
<asp:CheckBox ID="CheckBox1" runat="server" Visible="false" />
</div>
<br/>
</div>
</div>
</div>
<div class="step-pane" id="step3">
<h1>Matchmaking starts at
<asp:DropDownList ID="StartTime_DDL" runat="server" Style="color: #727272 !important; font-size: 24px; font-weight: 100;" CssClass="span2">
<asp:ListItem Text="9:00 AM"></asp:ListItem>
<asp:ListItem Text="9:30 AM"></asp:ListItem>
<asp:ListItem Text="10:00 AM"></asp:ListItem>
<asp:ListItem Text="10:30 AM"></asp:ListItem>
<asp:ListItem Text="11:00 AM"></asp:ListItem>
<asp:ListItem Text="11:30 AM"></asp:ListItem>
<asp:ListItem Text="12:00 PM"></asp:ListItem>
<asp:ListItem Text="12:30 PM"></asp:ListItem>
<asp:ListItem Text="1:00 PM"></asp:ListItem>
<asp:ListItem Text="1:30 PM"></asp:ListItem>
<asp:ListItem Text="2:00 PM"></asp:ListItem>
<asp:ListItem Text="2:30 PM"></asp:ListItem>
<asp:ListItem Text="3:00 PM"></asp:ListItem>
<asp:ListItem Text="3:30 PM"></asp:ListItem>
<asp:ListItem Text="4:00 PM"></asp:ListItem>
<asp:ListItem Text="4:30 PM"></asp:ListItem>
</asp:DropDownList>
and ends at
<asp:DropDownList ID="EndTime_DDL" runat="server" Style="color: #727272 !important; font-size: 24px; font-weight: 100;" CssClass="span2">
<asp:ListItem Text="9:00 AM"></asp:ListItem>
<asp:ListItem Text="9:30 AM"></asp:ListItem>
<asp:ListItem Text="10:00 AM"></asp:ListItem>
<asp:ListItem Text="10:30 AM"></asp:ListItem>
<asp:ListItem Text="11:00 AM"></asp:ListItem>
<asp:ListItem Text="11:30 AM"></asp:ListItem>
<asp:ListItem Text="12:00 PM"></asp:ListItem>
<asp:ListItem Text="12:30 PM"></asp:ListItem>
<asp:ListItem Text="1:00 PM"></asp:ListItem>
<asp:ListItem Text="1:30 PM"></asp:ListItem>
<asp:ListItem Text="2:00 PM"></asp:ListItem>
<asp:ListItem Text="2:30 PM"></asp:ListItem>
<asp:ListItem Text="3:00 PM"></asp:ListItem>
<asp:ListItem Text="3:30 PM"></asp:ListItem>
<asp:ListItem Text="4:00 PM"></asp:ListItem>
<asp:ListItem Text="4:30 PM"></asp:ListItem>
<asp:ListItem Text="5:00 PM"></asp:ListItem>
<asp:ListItem Text="5:30 PM"></asp:ListItem>
<asp:ListItem Text="6:00 PM"></asp:ListItem>
</asp:DropDownList>.
<br /><br />
Each slot is
<asp:DropDownList ID="SlotDuration_DDL" runat="server" Style="color: #727272 !important; font-size: 24px; font-weight: 100;" CssClass="span2" OnSelectedIndexChanged="SlotDuration_DDL_SelectedIndexChanged">
<asp:ListItem>10</asp:ListItem>
<asp:ListItem>15</asp:ListItem>
<asp:ListItem>20</asp:ListItem>
<asp:ListItem>25</asp:ListItem>
<asp:ListItem>30</asp:ListItem>
<asp:ListItem>35</asp:ListItem>
<asp:ListItem>40</asp:ListItem>
<asp:ListItem>45</asp:ListItem>
<asp:ListItem>50</asp:ListItem>
<asp:ListItem>55</asp:ListItem>
<asp:ListItem>60</asp:ListItem>
</asp:DropDownList>
minutes long. </h1>
</div>
<div class="step-pane" id="step4">
<div class="control-group ">
<h1>The following slots are available for Matchmaking.
<br/>
</h1>
<div class="alert alert-info">
Turn off any slots you wish to disable.
</div>
<div class="row-fluid">
<div class="span6">
<h1>
<asp:Label ID="Date_label" runat="server"></asp:Label>
</h1>
<div class="task low" runat="server" id="Timediv">
</div>
<div class="clearfix"></div>
</div>
</div>
</div>
</div>
</div>
<div class="step-pane" id="step5">
<h1>Your event is ready!</h1>
</div>
</div>
</div>
</div>
<!--/span-->
</div>
<!--/row-->
</div>
<!-- end: Content -->
</div>
<!--/fluid-row-->
代码背后......
protected void EventDuration_DDL_SelectedIndexChanged(object sender, EventArgs e)
{
int n = Int32.Parse(EventDuration_DDL.SelectedItem.ToString());
for (int i = 0; i < n; i++)
{
Label NewLabel = new Label();
NewLabel.ID = "Label" + i;
var eventDate = Calendar1.SelectedDate.Date.AddDays(i);
NewLabel.Text = eventDate.ToLongDateString();
CheckBox newcheck = new CheckBox();
newcheck.ID = "CheckBox" + i;
this.Labeldiv.Controls.Add(new LiteralControl("<span class='h1size'>"));
this.Labeldiv.Controls.Add(NewLabel);
this.Labeldiv.Controls.Add(new LiteralControl("</span>"));
this.Labeldiv.Controls.Add(new LiteralControl("<div class='make-switch pull-right' data-on='info'>"));
this.Labeldiv.Controls.Add(newcheck);
this.Labeldiv.Controls.Add(new LiteralControl("</div>"));
this.Labeldiv.Controls.Add(new LiteralControl("<br/>"));
}
}
protected void SlotDuration_DDL_SelectedIndexChanged(object sender, EventArgs e)
{
Date_label.Text = Calendar1.SelectedDate.ToShortDateString();
DateTime start = DateTime.Parse(StartTime_DDL.SelectedItem.Text);
DateTime end = DateTime.Parse(EndTime_DDL.SelectedItem.Text);
double duration = double.Parse(SlotDuration_DDL.SelectedItem.Text);
string header = "<div class='priority low'><span><strong>{0}</strong></span></div>";
string header1 = "<div class='priority medium'><span><strong>{0}</strong></span></div>";
string morning = "";
string afternon = "";
bool doneMornHeader = false, doneAfternoonHeader = false;
while (true)
{
DateTime dtNext = start.AddMinutes(duration);
if (start > end || dtNext > end)
break;
if (start < DateTime.Parse("12:00 PM"))
{
if (!doneMornHeader)
{
Label head = new Label();
head.Text = string.Format(header, "Morning");
this.Timediv.Controls.Add(head);
doneMornHeader = true;
}
morning = start.ToShortTimeString() + "-" + dtNext.ToShortTimeString();
Label lbl = new Label();
lbl.Text = morning;
CheckBox cb = new CheckBox();
this.Timediv.Controls.Add(new LiteralControl("<div class='span6'><div class='task low'>"));
this.Timediv.Controls.Add(new LiteralControl("<div class='desc'>"));
this.Timediv.Controls.Add(new LiteralControl("<div class='title'>"));
this.Timediv.Controls.Add(lbl);
this.Timediv.Controls.Add(new LiteralControl("<div class='make-switch span5 pull-right' data-on='success'>"));
this.Timediv.Controls.Add(cb);
this.Timediv.Controls.Add(new LiteralControl("</div>"));
this.Timediv.Controls.Add(new LiteralControl("</div>"));
this.Timediv.Controls.Add(new LiteralControl("</div>"));
this.Timediv.Controls.Add(new LiteralControl("</div>"));
this.Timediv.Controls.Add(new LiteralControl("<br>"));
}
else
{
if (!doneAfternoonHeader)
{
Label head = new Label();
head.Text = string.Format(header1, "Afternoon");
this.Timediv.Controls.Add(head);
doneAfternoonHeader = true;
}
afternon = start.ToShortTimeString() + "-" + dtNext.ToShortTimeString();
Label lbl1 = new Label();
lbl1.Text = afternon;
CheckBox cb1 = new CheckBox();
this.Timediv.Controls.Add(new LiteralControl("<div class='span6'><div class='task low'>"));
this.Timediv.Controls.Add(new LiteralControl("<div class='desc'>"));
this.Timediv.Controls.Add(new LiteralControl("<div class='title'>"));
this.Timediv.Controls.Add(lbl1);
this.Timediv.Controls.Add(new LiteralControl("<div class='make-switch span5 pull-right' data-on='success'>"));
this.Timediv.Controls.Add(cb1);
this.Timediv.Controls.Add(new LiteralControl("</div>"));
this.Timediv.Controls.Add(new LiteralControl("</div>"));
this.Timediv.Controls.Add(new LiteralControl("</div>"));
this.Timediv.Controls.Add(new LiteralControl("<br>"));
}
start = dtNext;
}
}
事件没有奏效..........
任何解决方案请...............!
还有一个问题是将一天或多天添加到来自文本框????
的日期答案 0 :(得分:1)
设置为<asp: DropDownList>
OnSelectedIndexChanged
事件的AutoPostback = True
,<asp:DropDownList ID="EventDuration_DDL" runat="server" AutoPostback="True" Style="color: #727272 !important; font-size: 24px; font-weight: 100;" CssClass="span1" OnSelectedIndexChanged="EventDuration_DDL_SelectedIndexChanged" >
即可。
示例:
{{1}}
答案 1 :(得分:1)
尝试将<asp:DropDownList>
AutoPostBack 设置为 true :
<asp:DropDownList ID="EventDuration_DDL" AutoPostBack="True" runat="server" Style="color: #727272 !important; font-size: 24px; font-weight: 100;" CssClass="span1" OnSelectedIndexChanged="EventDuration_DDL_SelectedIndexChanged">
为DateTime
使用添加天数:
YourDateTime = YourDateTime.AddDays(1);
答案 2 :(得分:0)
@ Thor ..对于从服务器端下拉工作,您需要将AutoPostBack属性设置为true,如果您的设计是向导步骤类型并且它转到步骤1那么这将是一个不好的做法,但您可以明确设置下拉处理完成后,向导将进入当前步骤。
如果您使用的是.net向导,请使用ajax更新面板,然后您将仅保持当前步骤。