vidhya

vidhya

  • NA
  • 324
  • 88.3k

dynamic control disappears when i refresh or close the page

Jul 24 2013 4:57 AM
I need to add the control in the page at the run time. i have a code to add the control dynamically. but the control disappears when i refresh the page or close the page. i need to display the controls in the page itself when i refresh or close the page.

<script type="text/javascript">
  $(document).ready(function()
  {
    $("#txt").click(function()
    {
        var $ctrl = $('<input/>').attr({ type: 'text', name:'text', value:'text'}).addClass("text");
        $("#holder").append($ctrl);
    });
   }
</script>
  @using (Html.BeginForm())
      {
<div>
  <fieldset>
                <legend><span>2.</span> Statements & Responses</legend>
               <input type="button" id="txt" value="Add TextBox" style="" />
               <div id="holder">
             </div>
 </fieldset>
</div>
}

Answers (22)