Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. postback issue with dynamically created datetimepicker

postback issue with dynamically created datetimepicker

Scheduled Pinned Locked Moved C#
javascripthelphtmldesigntools
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dhyanga
    wrote on last edited by
    #1

    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)
    {

    L 1 Reply Last reply
    0
    • D Dhyanga

      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)
      {

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Please use the correct forum: http://www.codeproject.com/Forums/12076/ASP-NET.aspx[^] or http://www.codeproject.com/Forums/1580226/JavaScript.aspx[^].

      D 1 Reply Last reply
      0
      • L Lost User

        Please use the correct forum: http://www.codeproject.com/Forums/12076/ASP-NET.aspx[^] or http://www.codeproject.com/Forums/1580226/JavaScript.aspx[^].

        D Offline
        D Offline
        Dhyanga
        wrote on last edited by
        #3

        Thanks. Yes I did.

        Dhyanga

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups