postback issue with dynamically created datetimepicker
-
Hi, I am using dynamic datetimepicker that the user can add to any number. But I am having postback problem. Once I submit it, the return page should have all the submitted values including those added dynamic datetimepicker. Right now when i submit and when the page returns, all other static controls with data are there but no dynamically added datetimepicker controls. Below is the code I used to add datatimepicker dynamically using javascript:
<html>
<script type="text/javascript" src="jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="jquery-ui.min.js"></script>
<script type="text/javascript" src="jquery-ui-timepicker-addon.js"></script>
<script type="text/javascript" src="jquery-ui-sliderAccess.js"></script>
<script type="text/javascript">
$(function () {var counter = 1; jQuery("#<%= btnD1Add.ClientID %>").click(function (event) { event.preventDefault(); //this code is added to prevent the default submit functionality of the button jQuery("* ").appendTo(".Date1More"); jQuery("<label id='lblD1StartTime" + counter + "'>StartTime:</label><input type='text' id='txtD1StartTime" +counter + "' name='txtStartTime1'/>").timepicker({ hourGrid: 10, minuteGrid: 10, timeFormat: 'hh:mm tt' }).appendTo(".Date1More"); counter++; }); }); </script>
</html>
Now how to use postback for these controls? I had tried to use following code in code but didn't work. I even tried it using !Ispostback() function under pageLoad but no effect.
protected string[] txtStartTime1;
protected void Page_Load(object sender, EventArgs e)
{txtStartTime1 = Request.Form.GetValues("txtStartTime1"); }
protected void Page_Init(object sender, EventArgs e)
{ -
Hi, I am using dynamic datetimepicker that the user can add to any number. But I am having postback problem. Once I submit it, the return page should have all the submitted values including those added dynamic datetimepicker. Right now when i submit and when the page returns, all other static controls with data are there but no dynamically added datetimepicker controls. Below is the code I used to add datatimepicker dynamically using javascript:
<html>
<script type="text/javascript" src="jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="jquery-ui.min.js"></script>
<script type="text/javascript" src="jquery-ui-timepicker-addon.js"></script>
<script type="text/javascript" src="jquery-ui-sliderAccess.js"></script>
<script type="text/javascript">
$(function () {var counter = 1; jQuery("#<%= btnD1Add.ClientID %>").click(function (event) { event.preventDefault(); //this code is added to prevent the default submit functionality of the button jQuery("* ").appendTo(".Date1More"); jQuery("<label id='lblD1StartTime" + counter + "'>StartTime:</label><input type='text' id='txtD1StartTime" +counter + "' name='txtStartTime1'/>").timepicker({ hourGrid: 10, minuteGrid: 10, timeFormat: 'hh:mm tt' }).appendTo(".Date1More"); counter++; }); }); </script>
</html>
Now how to use postback for these controls? I had tried to use following code in code but didn't work. I even tried it using !Ispostback() function under pageLoad but no effect.
protected string[] txtStartTime1;
protected void Page_Load(object sender, EventArgs e)
{txtStartTime1 = Request.Form.GetValues("txtStartTime1"); }
protected void Page_Init(object sender, EventArgs e)
{Please use the correct forum: http://www.codeproject.com/Forums/12076/ASP-NET.aspx[^] or http://www.codeproject.com/Forums/1580226/JavaScript.aspx[^].
-
Please use the correct forum: http://www.codeproject.com/Forums/12076/ASP-NET.aspx[^] or http://www.codeproject.com/Forums/1580226/JavaScript.aspx[^].