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("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"));

            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("&nbsp;&nbsp;"));

            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("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"));

            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);
            
        }

Hey just add a function as follows

<% @Page Language="C#" runat="server">
<html>
<head>
<script language="C#" runat="server">
public void btn_click(object s,EventArgs e)
{
  objectname.Items.Add("the name u wanna add");
}
</script>
</head>
<body>
<form>
<asp:button id="btnsubmit" text="Submit" onclick="btn_click" runat="server">
</form>
</body>
</html>

Hey just add a function as follows

<% @Page Language="C#" runat="server">
<html>
<head>
<script language="C#" runat="server">
public void btn_click(object s,EventArgs e)
{
  objectname.Items.Add("the name u wanna add");
}
</script>
</head>
<body>
<form>
<asp:button id="btnsubmit" text="Submit" onclick="btn_click" runat="server">
</form>
</body>
</html>

Thanks, but could you give more details? I don't understand what you mean!

This question has already been answered. Start a new discussion instead.