Click here to Skip to main content
15,891,905 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i am using emojis for my chat application and i wnt it to be displayed on my textbox when i click on one of emojies i have. which are inserted from database.

actually i tried code on item command event.. like below
but the problem is how to display that emojis special images to the textbox.

What I have tried:

<div class="send-message">
    <div class="input-group">
        <asp:TextBox ID="txttosnd" class="form-control" runat="server" placeholder="Type your message"></asp:TextBox>
        <asp:Panel ID="panemoji" class="form-control" runat="server">
            <asp:ImageButton ID="img" runat="server" ImageUrl="~/images/emoji_icon.jpeg" OnClick="img_Click" />
        </asp:Panel>
        <asp:Panel style="left:100px" ID="panemoj" runat="server" Visible="false">
             <asp:DataList ID="dlemojrep"  runat="server" RepeatDirection="Horizontal" OnItemCommand="dlemojrep_ItemCommand" RepeatColumns="4" RepeatLayout="Table">
                <ItemTemplate>
                    <asp:ImageButton runat="server" Style="margin: 0px 5px 5px 0px;" Width="30px" Height="30px" CommandArgument='<%#Eval("emojies_id") %>' CommandName="imgemoji" class="img-responsive" ID="imgbtn" alt="user" ImageUrl='<%# "~/ImagePage.aspx?emojiid=" + System.Convert.ToString(Eval("emojies_id")) %>' />
                </ItemTemplate>
            </asp:DataList>
        </asp:Panel>
        <span class="input-group-btn">
            <asp:Button ID="btnsndmsg" runat="server" CssClass="btn btn-default" OnClick="btnsndmsg_Click" Text="Send" />
        </span>
    </div>
</div>

rotected void dlemojrep_ItemCommand(object source, DataListCommandEventArgs e)
    {
        int USER_ID = Convert.ToInt32(Session["USERID"]);
        if (USER_ID != 0)
        {
            if (e.CommandName == "imgemoji")
            {
                touid = Convert.ToInt32(e.CommandArgument);
                oluserid.Value = touid.ToString();
                SqlConnection conn = new SqlConnection(c.connStr);
                conn.Open();
                
                SqlCommand cmd = new SqlCommand("select emo_pic from tbl_emoji where emojies_id= '" + touid + "'", conn);
                int chatreqacc = Convert.ToInt32(cmd.ExecuteScalar());
                if (chatreqacc != 0)
                {
                    GetMessages();
                    tblchat.Visible = true;
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Sorry! you can not send message, your caht request has been declined');", true);
                    tblchat.Visible = false;
                }
            }
        }
    }
Posted
Updated 20-Mar-17 23:16pm
v3
Comments
CHill60 13-Mar-17 5:33am    
And what have you tried to do to achieve that aim?
Member 11936990 14-Mar-17 5:35am    
actually i tried code on item command event.. like below
 protected void dlemojrep_ItemCommand(object source, DataListCommandEventArgs e)
    {
        int USER_ID = Convert.ToInt32(Session["USERID"]);
        if (USER_ID != 0)
        {
            if (e.CommandName == "imgemoji")
            {
                touid = Convert.ToInt32(e.CommandArgument);
                oluserid.Value = touid.ToString();
                SqlConnection conn = new SqlConnection(c.connStr);
                conn.Open();
                
                SqlCommand cmd = new SqlCommand("select emo_pic from tbl_emoji where emojies_id= '" + touid + "'", conn);
                int chatreqacc = Convert.ToInt32(cmd.ExecuteScalar());
                if (chatreqacc != 0)
                {
                    GetMessages();
                    tblchat.Visible = true;
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Sorry! you can not send message, your caht request has been declined');", true);
                    tblchat.Visible = false;
                }
            }
        }
    }

but the problem is how to dispay that emojis special images to the textbox.
CHill60 14-Mar-17 5:53am    
Well a TextBox will hold text. If you want to include images then you should use a RichTextBox[^]
Member 11936990 21-Mar-17 4:54am    
ok thanku.

1 solution

As per my comment, if you want to display both text and images you need to use a RichTextBox[^] instead of a TextBox
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900