Textarea New Line on Enter Key not working on .NET Core MVC Application












0















I have a (probably) simple issue that I can't solve and need your help to resolve.



I created a new MVC application with Visual Studio 2017. I then created the necessary Model, View, and Controller to add some data to a SQL Server database.

However, in the TEXTAREA input, I am not able to use the Enter Key to go to a new line, like I am able to do here when I submitted this question. The Enter key does nothing.



I tried to trace the issue and was able to use this script to confirm that the Enter key was detected; however, still can't get a new line when I pressed the Enter key.



                <script>
$(window).keydown(function (event) {
if ((event.which == 13) && ($(event.target)[0] == $("textarea")[0])) {
alert("One");
// event.preventDefault();
// return false;
}
});
</script>


Second, I added an onclick event to the textarea itself and still did not get a new line when clicked. There must be an override for the textarea in code that I am not able to find, which is probably part of the default app build in .NET VS2017.



<textarea rows="6" cols="20" class="form-control" asp-for="Notes" style="width: 96% !important;" onclick="this.value='Hello n How R U?'"></textarea>


Is there any way to correct this issue and gain access to the full TEXTAREA functionalities and be able to provide a full text-based area for users to provide detailed comments in multiple lines?



Thank you for your reply.










share|improve this question



























    0















    I have a (probably) simple issue that I can't solve and need your help to resolve.



    I created a new MVC application with Visual Studio 2017. I then created the necessary Model, View, and Controller to add some data to a SQL Server database.

    However, in the TEXTAREA input, I am not able to use the Enter Key to go to a new line, like I am able to do here when I submitted this question. The Enter key does nothing.



    I tried to trace the issue and was able to use this script to confirm that the Enter key was detected; however, still can't get a new line when I pressed the Enter key.



                    <script>
    $(window).keydown(function (event) {
    if ((event.which == 13) && ($(event.target)[0] == $("textarea")[0])) {
    alert("One");
    // event.preventDefault();
    // return false;
    }
    });
    </script>


    Second, I added an onclick event to the textarea itself and still did not get a new line when clicked. There must be an override for the textarea in code that I am not able to find, which is probably part of the default app build in .NET VS2017.



    <textarea rows="6" cols="20" class="form-control" asp-for="Notes" style="width: 96% !important;" onclick="this.value='Hello n How R U?'"></textarea>


    Is there any way to correct this issue and gain access to the full TEXTAREA functionalities and be able to provide a full text-based area for users to provide detailed comments in multiple lines?



    Thank you for your reply.










    share|improve this question

























      0












      0








      0








      I have a (probably) simple issue that I can't solve and need your help to resolve.



      I created a new MVC application with Visual Studio 2017. I then created the necessary Model, View, and Controller to add some data to a SQL Server database.

      However, in the TEXTAREA input, I am not able to use the Enter Key to go to a new line, like I am able to do here when I submitted this question. The Enter key does nothing.



      I tried to trace the issue and was able to use this script to confirm that the Enter key was detected; however, still can't get a new line when I pressed the Enter key.



                      <script>
      $(window).keydown(function (event) {
      if ((event.which == 13) && ($(event.target)[0] == $("textarea")[0])) {
      alert("One");
      // event.preventDefault();
      // return false;
      }
      });
      </script>


      Second, I added an onclick event to the textarea itself and still did not get a new line when clicked. There must be an override for the textarea in code that I am not able to find, which is probably part of the default app build in .NET VS2017.



      <textarea rows="6" cols="20" class="form-control" asp-for="Notes" style="width: 96% !important;" onclick="this.value='Hello n How R U?'"></textarea>


      Is there any way to correct this issue and gain access to the full TEXTAREA functionalities and be able to provide a full text-based area for users to provide detailed comments in multiple lines?



      Thank you for your reply.










      share|improve this question














      I have a (probably) simple issue that I can't solve and need your help to resolve.



      I created a new MVC application with Visual Studio 2017. I then created the necessary Model, View, and Controller to add some data to a SQL Server database.

      However, in the TEXTAREA input, I am not able to use the Enter Key to go to a new line, like I am able to do here when I submitted this question. The Enter key does nothing.



      I tried to trace the issue and was able to use this script to confirm that the Enter key was detected; however, still can't get a new line when I pressed the Enter key.



                      <script>
      $(window).keydown(function (event) {
      if ((event.which == 13) && ($(event.target)[0] == $("textarea")[0])) {
      alert("One");
      // event.preventDefault();
      // return false;
      }
      });
      </script>


      Second, I added an onclick event to the textarea itself and still did not get a new line when clicked. There must be an override for the textarea in code that I am not able to find, which is probably part of the default app build in .NET VS2017.



      <textarea rows="6" cols="20" class="form-control" asp-for="Notes" style="width: 96% !important;" onclick="this.value='Hello n How R U?'"></textarea>


      Is there any way to correct this issue and gain access to the full TEXTAREA functionalities and be able to provide a full text-based area for users to provide detailed comments in multiple lines?



      Thank you for your reply.







      asp.net-mvc textarea






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 24 '18 at 17:41









      JohnnyJohnny

      3018




      3018
























          1 Answer
          1






          active

          oldest

          votes


















          1














          I wrote following HTML code to face your problem but there was no problem!



          <html>
          <head>
          <title>
          test
          </title>
          </head>
          <body>
          <textarea rows="6" cols="20" class="form-control" asp-for="Notes" style="width: 96% !important;"

          onclick="this.value='Hello n How R U?'"></textarea>
          </body>
          </html>


          Did you check your application by another browser?
          If the problem still remains, In your browser inspect HTML code of your textarea and compare it to the tag helper equivalent of the textarea in your view code. This may help you to figure something out.






          share|improve this answer



















          • 1





            I was using a jquery implementation code on the header of the page. I removed it and was then able to use the enter key on the textarea. Hence, I found another more current jquery datepicker implementation, which does not seem to interfere with the rest of the CSS and JS scripts. Specifically, I was using JQuery version 3.3.1 (code.jquery.com/jquery-3.3.1.min.js), which is preventing enter key carriage return to generate a new line on TextArea forms. Once I changed to JQuery 1.12.4 (code.jquery.com/jquery-1.12.4.js) the page (textarea) is working again.

            – Johnny
            Nov 26 '18 at 2:08











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53460796%2ftextarea-new-line-on-enter-key-not-working-on-net-core-mvc-application%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          I wrote following HTML code to face your problem but there was no problem!



          <html>
          <head>
          <title>
          test
          </title>
          </head>
          <body>
          <textarea rows="6" cols="20" class="form-control" asp-for="Notes" style="width: 96% !important;"

          onclick="this.value='Hello n How R U?'"></textarea>
          </body>
          </html>


          Did you check your application by another browser?
          If the problem still remains, In your browser inspect HTML code of your textarea and compare it to the tag helper equivalent of the textarea in your view code. This may help you to figure something out.






          share|improve this answer



















          • 1





            I was using a jquery implementation code on the header of the page. I removed it and was then able to use the enter key on the textarea. Hence, I found another more current jquery datepicker implementation, which does not seem to interfere with the rest of the CSS and JS scripts. Specifically, I was using JQuery version 3.3.1 (code.jquery.com/jquery-3.3.1.min.js), which is preventing enter key carriage return to generate a new line on TextArea forms. Once I changed to JQuery 1.12.4 (code.jquery.com/jquery-1.12.4.js) the page (textarea) is working again.

            – Johnny
            Nov 26 '18 at 2:08
















          1














          I wrote following HTML code to face your problem but there was no problem!



          <html>
          <head>
          <title>
          test
          </title>
          </head>
          <body>
          <textarea rows="6" cols="20" class="form-control" asp-for="Notes" style="width: 96% !important;"

          onclick="this.value='Hello n How R U?'"></textarea>
          </body>
          </html>


          Did you check your application by another browser?
          If the problem still remains, In your browser inspect HTML code of your textarea and compare it to the tag helper equivalent of the textarea in your view code. This may help you to figure something out.






          share|improve this answer



















          • 1





            I was using a jquery implementation code on the header of the page. I removed it and was then able to use the enter key on the textarea. Hence, I found another more current jquery datepicker implementation, which does not seem to interfere with the rest of the CSS and JS scripts. Specifically, I was using JQuery version 3.3.1 (code.jquery.com/jquery-3.3.1.min.js), which is preventing enter key carriage return to generate a new line on TextArea forms. Once I changed to JQuery 1.12.4 (code.jquery.com/jquery-1.12.4.js) the page (textarea) is working again.

            – Johnny
            Nov 26 '18 at 2:08














          1












          1








          1







          I wrote following HTML code to face your problem but there was no problem!



          <html>
          <head>
          <title>
          test
          </title>
          </head>
          <body>
          <textarea rows="6" cols="20" class="form-control" asp-for="Notes" style="width: 96% !important;"

          onclick="this.value='Hello n How R U?'"></textarea>
          </body>
          </html>


          Did you check your application by another browser?
          If the problem still remains, In your browser inspect HTML code of your textarea and compare it to the tag helper equivalent of the textarea in your view code. This may help you to figure something out.






          share|improve this answer













          I wrote following HTML code to face your problem but there was no problem!



          <html>
          <head>
          <title>
          test
          </title>
          </head>
          <body>
          <textarea rows="6" cols="20" class="form-control" asp-for="Notes" style="width: 96% !important;"

          onclick="this.value='Hello n How R U?'"></textarea>
          </body>
          </html>


          Did you check your application by another browser?
          If the problem still remains, In your browser inspect HTML code of your textarea and compare it to the tag helper equivalent of the textarea in your view code. This may help you to figure something out.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 24 '18 at 19:01









          vahidvahid

          1364




          1364








          • 1





            I was using a jquery implementation code on the header of the page. I removed it and was then able to use the enter key on the textarea. Hence, I found another more current jquery datepicker implementation, which does not seem to interfere with the rest of the CSS and JS scripts. Specifically, I was using JQuery version 3.3.1 (code.jquery.com/jquery-3.3.1.min.js), which is preventing enter key carriage return to generate a new line on TextArea forms. Once I changed to JQuery 1.12.4 (code.jquery.com/jquery-1.12.4.js) the page (textarea) is working again.

            – Johnny
            Nov 26 '18 at 2:08














          • 1





            I was using a jquery implementation code on the header of the page. I removed it and was then able to use the enter key on the textarea. Hence, I found another more current jquery datepicker implementation, which does not seem to interfere with the rest of the CSS and JS scripts. Specifically, I was using JQuery version 3.3.1 (code.jquery.com/jquery-3.3.1.min.js), which is preventing enter key carriage return to generate a new line on TextArea forms. Once I changed to JQuery 1.12.4 (code.jquery.com/jquery-1.12.4.js) the page (textarea) is working again.

            – Johnny
            Nov 26 '18 at 2:08








          1




          1





          I was using a jquery implementation code on the header of the page. I removed it and was then able to use the enter key on the textarea. Hence, I found another more current jquery datepicker implementation, which does not seem to interfere with the rest of the CSS and JS scripts. Specifically, I was using JQuery version 3.3.1 (code.jquery.com/jquery-3.3.1.min.js), which is preventing enter key carriage return to generate a new line on TextArea forms. Once I changed to JQuery 1.12.4 (code.jquery.com/jquery-1.12.4.js) the page (textarea) is working again.

          – Johnny
          Nov 26 '18 at 2:08





          I was using a jquery implementation code on the header of the page. I removed it and was then able to use the enter key on the textarea. Hence, I found another more current jquery datepicker implementation, which does not seem to interfere with the rest of the CSS and JS scripts. Specifically, I was using JQuery version 3.3.1 (code.jquery.com/jquery-3.3.1.min.js), which is preventing enter key carriage return to generate a new line on TextArea forms. Once I changed to JQuery 1.12.4 (code.jquery.com/jquery-1.12.4.js) the page (textarea) is working again.

          – Johnny
          Nov 26 '18 at 2:08


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53460796%2ftextarea-new-line-on-enter-key-not-working-on-net-core-mvc-application%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

          Calculate evaluation metrics using cross_val_predict sklearn

          Insert data from modal to MySQL (multiple modal on website)