Hi All!
I have this Button_Click event. I want it to create as many set of the specified below controls as User clicks. For example: If the user clicks one the button then only 1 line set of these controls will appear on the PlaceHolder but if the user clicks 2 times the button then I want it to appear 2 sets of these controls on the PlaceHolder.
With the code I wrote it only adds one set and when I click 2nd time the Button it just refreshes the same set of controls - in other words it doesn't create a new line set of the controls.
Any help would be highly appreciated!
Thanks!
Donish.
protected void addStudioButton_Click(object sender, EventArgs e) {
reservationPlaceHolder.Controls.Add(new LiteralControl("<br />"));
Label studioLabel = new Label();
studioLabel.Text = "Studio: ";
studioLabel.ID = "studioLabel";
reservationPlaceHolder.Controls.Add(studioLabel);
reservationPlaceHolder.Controls.Add(new LiteralControl(" "));
Label startDateLabel = new Label();
startDateLabel.Text = "Start Date: ";
reservationPlaceHolder.Controls.Add(startDateLabel);
TextBox txtStartDate = new TextBox();
txtStartDate.ID = "txtStartDate";
txtStartDate.Width = 70;
reservationPlaceHolder.Controls.Add(txtStartDate);
HyperLink startDateCalendar = new HyperLink();
startDateCalendar.NavigateUrl = "javascript:calendar_window=window.open('calendar.aspx?formname=aspnetForm." + txtStartDate.ClientID + "','calendar_window','width=180,height=240');calendar_window.focus()";
startDateCalendar.ImageUrl = "~/Image/SmallCalendar.gif";
reservationPlaceHolder.Controls.Add(startDateCalendar);
reservationPlaceHolder.Controls.Add(new LiteralControl(" "));
Label endDateLabel = new Label();
endDateLabel.Text = "End Date: ";
reservationPlaceHolder.Controls.Add(endDateLabel);
TextBox txtEndDate = new TextBox();
txtEndDate.ID = "txtEndDate";
txtEndDate.Width = 70;
reservationPlaceHolder.Controls.Add(txtEndDate);
HyperLink endDateCalendar = new HyperLink();
endDateCalendar.NavigateUrl = "javascript:calendar_window=window.open('calendar.aspx?formname=aspnetForm." + txtEndDate.ClientID + "','calendar_window','width=180,height=240');calendar_window.focus()";
endDateCalendar.ImageUrl = "~/Image/SmallCalendar.gif";
reservationPlaceHolder.Controls.Add(endDateCalendar);
reservationPlaceHolder.Controls.Add(new LiteralControl(" "));
DropDownList studioTypeDropDownList = new DropDownList();
studioTypeDropDownList.Width = 200;
studioTypeDropDownList.Items.Add("Large");
studioTypeDropDownList.Items.Add("Medium");
studioTypeDropDownList.Items.Add("Small");
studioTypeDropDownList.ID = "studioTypeDropDownList";
reservationPlaceHolder.Controls.Add(studioTypeDropDownList);
}