Assign datepicker to runtime/dynamic textboxes in ASP.NET using jQuery

Category > ASP.NET || Published on : Thursday, February 11, 2016 || Views: 8224 || Assign datepicker to runtime/dynamic textboxes in ASP.NET using jQuery


Introduction

Here Pawan Kumar will explain how to Assign datepicker to runtime/dynamic textboxes in ASP.NET using jQuery

Description

In previous post I have explained How to display image on image selection using fileupload control in JQuery., Add TextBox Dynamically ASP.Net on Click ASP.Net Button, Mask UnMask Input Text jQuery Html, JavaScript Alert Message Dialog Box, Save data to database without postback using jQuery ajax in ASP.NET, How to set focus on first textbox of the page, and many more articles.

Now I will explain How to Assign datepicker to runtime/dynamic textboxes in ASP.NET using jQuery

So follow the steps to learn Assign datepicker to runtime/dynamic textboxes in ASP.NET using jQuery

ASPX Code:-

protected void Page_Load(object sender, EventArgs e)
    {
        for (int b = 0; b < 3; b++)
        {
                TextBox txtdate = new TextBox();
                txtdate.ID = "dpicker" + b.ToString();
                txtdate.CssClass = "date";   // class date
                 PlaceHolder1.Controls.Add(txtdate);
            }
    }

Code Behind:-

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
   <link type="text/css" rel="Stylesheet" href="http://ajax.microsoft.com/ajax/jquery.ui/1.8.6/themes/smoothness/jquery-ui.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" >
</script>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.ui/1.8.6/jquery-ui.min.js" >
</script>
<script type="text/javascript">
    $(function () {
        $(".date").datepicker();
    });
</script>
</head>
<body>

 

Conclusion:

So, In this tutorial we have learned, Assign datepicker to runtime/dynamic textboxes in ASP.NET using jQuery