Search code examples
htmlasp.netvb.netcontent-management-systeminnerhtml

InnerHTML attribute Shows The Tags at String


Hello Im Developing a Simple Cms That Generate Blogs however, The User Should enter The Blog Content buy im self and let him to do that with tinymce editor Now i save The Content OF that in a data base he Type of that database element is "Text" so far so good Right ? the problem is when i get the Content from the data base and a sign it with inner HTml it became like in that pictureHere Here is the Html Code

 `boddy.InnerHtml = " <div id='shareButtonsDiv'><div class='iframe_header'>
                                 <p>" & DetailsView1.Rows(0).Cells(1).Text & "</p>
                                 <span class='social_icons'>
                                     <span>Share on</span>
                                   <span class='twitter'>
                                       <a target='_blank' class='twitter-share-button'
                                           href='https://twitter.com/share'
                                          data-size='large'
                                          data-text='custom share text'
                                           data-url='https://dev.twitter.com/web/tweet-button'
                                          data-hashtags='example,demo'
                                          data-via='twitterdev'
                                          data-related='twitterapi,twitter'>
                                           <i class='fa fa-twitter' aria-hidden='true'></i></a>
                                    </span>
                                      <span class='facebook'>
                                          <script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;  js = d.createElement(s); js.id = id;
  js.src = '//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.8&appId=1074461072666302';
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
                                          <div class='fb-share-button' data-href='../blogs/1_1.html' data-layout='button' data-mobile-iframe='true'>                                            <a class='fb-xfbml-parse-ignore' target='_blank' href='https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2Fplugins%2F&amp;src=sdkpreparse'>Share</a>
                                          </div>
                                     </span>
                                 </span>
                             </div>  

                                   </div>
                                 
        <div class='iframe_content'>
	<div class='texts'>
			
				" + DetailsView1.Rows(2).Cells(1).Text + "
			
		</div>
	
	</div> "`


Solution

  • It would seem that your HTML code is escaped/encoded. Try using the HttpUtility.HtmlDecode() method:

    Dim Header As String = HttpUtility.HtmlDecode(DetailsView1.Rows(0).Cells(1).Text)
    Dim Texts As String = HttpUtility.HtmlDecode(DetailsView1.Rows(2).Cells(1).Text)
    

    ...then concatenate the HTML with those two variables instead.