title: Need to make selected text as bold/italic/underline using javascript, and also save & retrieve the same using c#
body: <p>I need to make selected text of textbox bold/italic/underline using javascript. For that i am using the following code.</p>
  
  <pre><code>&lt;img src="~/images/Bold"  alt="Bold" onclick="changeFont('TextBox1','b');"  /&gt;
  &lt;img src="~/images/Italic" alt="Italic" onclick="changeFont('TextBox1','i');"  /&gt;
  &lt;img src="~/images/Underline" alt="Underline" onclick="changeFont('TextBox1','u');"  /&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>&lt;script type="text/javascript" language="javascript"&gt;
      function changeFont(txt, change) {
          if (change == 'b') {
              if (document.getElementById(txt).style.fontWeight == 'bold')
                  document.getElementById(txt).style.fontWeight = 'normal';
              else
                  document.getElementById(txt).style.fontWeight = 'bold';
          }
          else if (change == 'i') {
              if (document.getElementById(txt).style.fontStyle == 'italic')
                  document.getElementById(txt).style.fontStyle = 'normal';
              else
                  document.getElementById(txt).style.fontStyle = 'italic';
          }
          else {
              if (document.getElementById(txt).style.textDecoration == 'underline')
                  document.getElementById(txt).style.textDecoration = 'none';
              else
                  document.getElementById(txt).style.textDecoration = 'underline';
          }
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>But the issue here is, when i click on bold image its making the whole text into bold but not the selected text. It´s not working for the other two images either.</p>
  
  <p>While saving the text of textbox I am unable to get the text including html tags even after trying with</p>
  
  <pre><code>document.getElementById('TextBox1').innerHTML;
  </code></pre>
  
  <p>I am able to get only the value of textbox.</p>
  
  <p>Is there any way to save and retrieve the same using javascript or C#</p>
  
  <p>Thanks in advance
  SC</p>