Tag Archives: Table Row & Cell Programmatically

ASP.Net Ajax Creating Multiple Calendar Extenders on TextBoxes Programmatically


A web app having multiple Textboxes and Date Pickers or Calendar Extenders are very common.
Usually a page for submitting more than one rows which include Date field.

If Textboxes with attached Calender depends on some logic then we need to create them programmatically.

I will show how to do it using Asp.Net Ajax Control Toolkit Calendar Extender as Date picker control. I also used the simple ‘Northwind’ sample Database for demo purpose.

This small application will show Employees Name, Title and Hire Date info. Hire Date can be choose using calendar extender & updated.

  1. Creating multiple TextBoxes and Calendar Extenders programmatically
    ...
    <form id="form1" runat="server">
        <div>
            <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
            </asp:ToolkitScriptManager>
            <asp:UpdatePanel ID="updpanel" runat="server">
            <ContentTemplate>
               
                <asp:Table ID="tblinput" runat="server" >
                    <asp:TableHeaderRow ID="TableHeaderRow1" runat="server" Font-Names="Calibri" Font-Size="10pt">
                        
                        <asp:TableHeaderCell>ID</asp:TableHeaderCell>
                        <asp:TableHeaderCell>Name</asp:TableHeaderCell>
                        <asp:TableHeaderCell>Title</asp:TableHeaderCell>
                        <asp:TableHeaderCell>Hire Date</asp:TableHeaderCell>
                    </asp:TableHeaderRow>
                    
                </asp:Table>
               
                <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
                <asp:Button ID="btnSubmit" runat="server" Text="Submit" 
                    onclick="btnSubmit_Click" />  <asp:Label ID="lblmsg" runat="server"></asp:Label>
                
            </ContentTemplate>
            </asp:UpdatePanel>
        </div>
        </form>
    ...
    

    I have Table Control as container of Labels & TextBoxes. Also PlaceHolder control that will be contained by AjaxControlToolkit Calendar Extender.

    Labels, TextBoxes and Calendar Extender created programmatically inside Page_Load procedure.

  2. Continue reading

Advertisements