Click here to Skip to main content
13,735,397 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
Can you help me regarding adding emoticons to our asp.net chat application.

please provide me the code for adding smileys to my asp.net website in c#.






Regards
sonam vij
Posted 27-Sep-12 21:47pm
Comments
Kenneth Haugland 28-Sep-12 4:00am
   
Pictures?
I.explore.code 28-Sep-12 4:13am
   
or GIF animations??
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

You need to write some type of text parser!

Here is a brief example:

public class EmoticonRender()
{

  private List<keyvaluepair<string,string>> _dictionary = new List<keyvaluepair<string,string>>() 
  {
    new KeyValuePair<string,>(":-)", "smile.png"),
    new KeyValuePair<string,>(";-(", "cry.png")
  }

  public string Parse(string text)
  {
    foreach(KeyValuePair<string,> kvp in _dictionary)
    {
      text = text.Replace(kvp.Key, "<img src="\""" kvp.value="" />");
    }
    return text;
  }

}


The class looks the the text representation of the emoticons and replaces them with the HTML required to render the images.

Usage is simple:

string text = "hello :-) don't be sad ;-(";
EmoticonRender parser = new EmoticonRender();
string parsedText = parser.Parse(text); 
  Permalink  
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

hello sonam, for your solution you could go-through the link "http://stackoverflow.com/questions/13528276/how-to-add-smiley-feature-in-chat-application-in-java" and for live demo (which using jquery for smiley) use link "http://jsfiddle.net/Etmrs/".....
  Permalink  
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

If you want selectable text with inserted emoticon images, I think you have 3 relatively simple options:

1. Use a WebBrowser instead of a TextBox and create html from your text+images.
2. Use a RichTextBox instead of a TextBox and insert your images into the RTF.
3. Buy a third party advanced TextBox-ish control which offers the ability to override the drawing event.

Or try : Inserting Plain Text and Images into RichTextBox at Runtime[^].


--Amit
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web05-2016 | 2.8.180920.1 | Last Updated 25 Jun 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100