c# - Get innerHTML from Div into mvc Model -


i work on mvc website, , have div contenteditable flag, it's big input field ( can't change ! ).

the div look's :

    <div id="email-text" contenteditable="true">            here editable text want      </div > 

now want text div model found no way it.

i don't know keywords helpful problem.

you have innerhtml of email-text via jquery or javascript before form submit , put input.

<form id="myform">       <input type="hidden" name="text" id="emailtextinput" />     <div id="email-text" contenteditable="true">            here editable text want      </div>     <input type="submit" name="submit" id="btn" /> </div> <script>     $(document).ready(function(){         $("#btn").on("click",function(){             var emailtext = $("#email-text").html();             $("#emailtextinput").val(emailtext);         });     }); </script> 

and in server side need view model following model

public class emailmodel {     public string text{ get; set; } }  

in controller:

public actionresult index(emailmodel emailmodel) {    ... } 

when click submit button jquery click event raised , text in div inner html copy hidden input.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -