locked
I dont know what title to give this..But I need help. RRS feed

  • Question

  • User-371148474 posted

    I've been updating forms for quite a while now, I just can't get a hold of this, There is this form that Updates a nvarchar field in the database, But after updating, It returns result with a comma appended to the last letter, I took it to another test scenario, spacing the letters, I found out after it turns some empty spaces to commas.. 

    E.g

    Culoe De Song, But I intended to have Culoe De Song

    here is my code

    if(IsPost && Request["fname"]!=null){ 
        var saved= "UPDATE UserProfile SET FName=@0 WHERE UserID=@1";
    db.Execute(saved,Request["fname"],WebSecurity.GetUserId(WebSecurity.CurrentUserName));
           string currentUrl =  Request.Url.LocalPath;
     Response.Redirect(currentUrl);
            }
    
                               <form action="" method="post">
                                     <div class="col-sm-9" style="margin-left:-15px;font-size: 11px;">   
                         <input type="text" class="form-control" name="fname" value="@user.Fname">
                                  </div>
                                          <div class=" col-sm-2" style="margin-right:-20px;font-size: 11px;">   
    
      <button style="font-size: 11px;" class='btn btn-default btn-round-sm btn-sm del' type='submit' name="fname">Save</button> 
                                         </div>
    </form>
    Note: @user.Fname is reading the existing value from the database.

    HOw do I get rid of the commas appending themselves to the updated field.
    Monday, December 8, 2014 5:29 PM

Answers

  • User-371148474 posted

    I changed my buttons to input buttons, and it stopeed appending the commas..

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 8, 2014 5:40 PM

All replies

  • User-371148474 posted

    I changed my buttons to input buttons, and it stopeed appending the commas..

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 8, 2014 5:40 PM
  • User379720387 posted

    You probably have a stray comma somewhere in your markup.

    Put a breakpoint in your IsPost, and look at the Request, then same thing before before you update the db.

    Monday, December 8, 2014 5:44 PM