2

I have a problem with C# ASP.NET ; I'm printing HTML to a page using C#. I tried using Labels and such, but it doesn't output the HTML as raw HTML, it just prints it with the actual <a href> instead of raw HTML to create the link. Here's what I got.

string _consumerKey = "---";
string _consumerSecret = "---";
string _accessToken = "---";
string _accessTokenSecret = "---";
var server = new TwitterService(_consumerKey, _consumerSecret);
server.AuthenticateWith(_accessToken, _accessTokenSecret);
var tweets = server.ListTweetsOnHomeTimeline(new ListTweetsOnHomeTimelineOptions());
foreach (var tweet in tweets)
{
    Response.Write("<li><a href=\"http://twitter.com/" + tweet.User.ScreenName + " \">@" + tweet.User.ScreenName + "</a> says  <<<< " + tweet.Text + " >>>></li>");
}

And it also prints the HTML at the top of the page instead of my <div id="tweetcontainer">.

Here is the ASPNET Code. The Response.Write prints it to the top of the page instead of in the container.

<div id="tweetcontainer">
     <asp:BulletedList ID="BulletedList1" runat="server">
     </asp:BulletedList>
</div>
John Saunders
  • 160,644
  • 26
  • 247
  • 397
Brandon Palmer
  • 313
  • 2
  • 11
  • You can't use the angle brackets in `<<<< " + tweet.Text + " >>>>` because many browsers will treat them as an HTML tag. – Moshe Katz Jun 23 '13 at 14:00
  • Still replaces – Brandon Palmer Jun 23 '13 at 14:07
  • I don't see `
    ` anywhere in your code sample. Please post the complete sample. (Please also be careful with escaping HTML in your question. Note that HTML tags in your text must be surrounded with ` (backticks) in order to be visible.)
    – Moshe Katz Jun 23 '13 at 14:11
  • is on the ASP.NET design page (VB2012) basicly, I need to move them from the top of the page. Here's the ASP.NET code. I added it above. – Brandon Palmer Jun 23 '13 at 14:15
  • I'm aware I need to use BulletedList1.Items.Add or List(); - but instead when I use that it doesn't parse the HTML as HTML, it makes it just HTML text, so you can see the and all. – Brandon Palmer Jun 23 '13 at 14:18
  • 3
    Hi - if you've solved your problem, please post the solution as an answer and accept it, so that people with similar issues in the future can see this resolution. – Ant P Jun 23 '13 at 15:10
  • 1
    I tried that, I have to wait like 8 hours or so because I have less than 10 rep. – Brandon Palmer Jun 23 '13 at 15:16
  • I have edited your title. Please see, "[Should questions include “tags” in their titles?](http://meta.stackexchange.com/questions/19190/)", where the consensus is "no, they should not". – John Saunders Jun 24 '13 at 01:43

1 Answers1

1

Figured it out. Put the code above in different void function, then in the ASP.NET page to put it in the div container I did the following:

<div id="tweets">
       <% _getTweets(); %>
</div>

That seemed to fix my problem.

Brandon Palmer
  • 313
  • 2
  • 11