Textbox value set by jquery is empty on save

4 posts, 0 answers
  1. Mattias
    Mattias avatar
    263 posts
    Member since:
    Aug 2012

    Posted 28 Feb 2013 Link to this post

    Hi,
    I set a textbox value from another textbox by jquery like this:
    $('input[id="Name"]').live('change keyup', function () {
       var urlSegment = $('input[id="UrlSegment"]');
       urlSegment.val("Test");
    });
    I can see the value "Test" in the second textbox but when clicking on save, the posted value is empty.
    I think the problem lies along with ajax cause when changing to server binding the value is posted.

    The form is generated in a popup by the grid.

    How do I solve this?

    Regards,
    Mattias
  2. todd
    todd avatar
    2 posts
    Member since:
    Apr 2011

    Posted 03 Mar 2013 Link to this post

    I'm having the same problem have you resolved this issue yet?
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Mattias
    Mattias avatar
    263 posts
    Member since:
    Aug 2012

    Posted 04 Mar 2013 Link to this post

    Hi Todd,
    It seems to work by adding .change() to the textbox.
    $('input[id="Name"]').live('change keyup', function () {
       var urlSegment = $('input[id="UrlSegment"]');
       urlSegment.val("Test");
       urlSegment.change();
    });

    /Mattias
  5. todd
    todd avatar
    2 posts
    Member since:
    Apr 2011

    Posted 04 Mar 2013 Link to this post

    Awesome that worked thanks!
Back to Top
UI for ASP.NET MVC is VS 2017 Ready