TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
yadagiri uppari
NA
277
190k
how to add emotions in datalist when send button clicked
Jun 25 2013 5:41 AM
how to add smiley in asp.net...please suggest me
aspx:
<body style="width: 487px; height: 331px">
<form id="form1" runat="server">
<div style="height:505px; width:574px; border-style:groove; border-top-width:medium;" >
<asp:panel ID="Panel1" runat="server" Height="504px" Width="574px"
BorderColor="#333333" BorderStyle="None">
<div style=" height:191px; width:574px; overflow:scroll">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Timer ID="Timer1" runat="server" Interval="10000" ontick="Timer1_Tick">
</asp:Timer>
<asp:DataList ID="dldisplayMessage" runat="server" Width="465px" Height= "100px">
<ItemTemplate>
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td>
<asp:LinkButton ID="lnksender" runat="server" Text='<%# Bind("SenderID") %>' Font-Underline="False" ForeColor="Blue" Visible= "true" />
</td>
<td>
<FTB:FreeTextBox ID="FTBMessage" runat="server" Text='<%# Bind("Message") %>' EnableHtmlMode="false"
EnableToolbars="False" FormatHtmlTagsToXhtml="true"
HtmlModeDefaultsToMonoSpaceFont="true" ReadOnly="true"
RemoveScriptNameFromBookmarks="True"
RenderMode="Rich" BackColor="White"
Height="100px" Width="200px" ToolbarBackColor="White" EditorBorderColorLight="White" EditorBorderColorDark="White"
BreakMode="LineBreak" StartMode="DesignMode"></FTB:FreeTextBox>
</td>
<td>
<asp:LinkButton ID="lnkDate" runat="server" Text='<%# Bind("Date") %>' Font-Underline="False" ForeColor="Blue" Visible= "true" />
</td>
<asp:Image ID="Image" runat="server" ImageUrl='<%# Bind("Image")%>' />
</tr>
</table>
</ItemTemplate>
</asp:DataList>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
</div>
<div style="border-style: ridge; height:41px; width:571px; border-top-width: medium;" >
<table class="style2">
<tr>
<td class="style3">
<asp:Button ID="btnHistory" runat="server" Text="History" CssClass="chatWindowButtons"
OnClick="btnHistory_Click" Height="28px" BackColor="#2B9DDB" />
</td>
<td class="style4">
       <asp:Button ID="btnChatRoom" runat="server"
Text="Invite chat room" CssClass="chatWindowButtons"
Width="117px" Height="28px" BackColor="#2B9DDB" />
</td>
<td>
      <asp:Image ID="imgSmiley" runat="server" Height="22px"
ImageUrl="images/smiley-1.png" Width="26px" />
</td>
<td>      <asp:Button ID="btnEmotion" runat="server"
Text="Emotions" Height="28px" CssClass="chatWindowButtons"
Width="56px" BackColor="#2B9DDB" onclick="btnEmotion_Click" />
</td>
</tr>
</table>
<br />
<br />
</div>
<table class="style6">
<tr>
<td class="style7">
<%--<div contenteditable="true" id="dvmain" onkeyup="replacewithimg(this);"> --%>
<FTB:FreeTextBox ID="FreeTextBox1" runat="server"
RenderMode="Rich" ScriptMode="External" StartMode="DesignMode"
EnableHtmlMode="false" Width="566px" Height="140px"
ToolbarBackColor="White" EditorBorderColorLight="white"
EditorBorderColorDark="White" BreakMode="LineBreak"></FTB:FreeTextBox> <%--</div>--%>
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnSend" runat="server" CssClass="chatWindowButtons" Height="30px"
onclick="btnSend_Click" Text="Send" Width="58px" BackColor="#2B9DDB" />
<%-- <asp:Button ID="btnEnter" runat="server" Text="" Visible="true"
onclick="btnEnter_Click" Height="0px" Width="0px"/>--%>
</td>
</tr>
</table>
<br />
<br />
<br />
</asp:panel>
</div>
</form>
</body>
</html>
codebehind:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using eBizLink_DAL;
using System.Data.SqlClient;
using System.Timers;
using System.Diagnostics;
using System.Windows.Forms;
public partial class ChatWindow : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Session["txtMessage"] = FreeTextBox1.Text;
Session["sender"] = 47;
Session["receiver"] = 52;
this.btnSend.Focus();
}
protected void btnSend_Click(object sender, EventArgs e)
{
try
{
GetImages();
SqlParameter param1 = new SqlParameter("@senderid", Session["sender"]);
SqlParameter param2 = new SqlParameter("@message", Session["txtMessage"]);
SqlParameter param3 = new SqlParameter("@date", DateTime.Now);
SqlParameter param7 = new SqlParameter("@receiverid", Session["receiver"]);
String stm = "sp_ChatInsert";
SqlHelper.ExecuteNonQuery(CommonSetting.GetConnectionString(true), CommandType.StoredProcedure, stm, param1, param2, param3, param7);
getMessage();
FreeTextBox1.Text = null;
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
public void getMessage()
{
try
{
string strSql = "sp_GetChatMessage";
SqlParameter param5 = new SqlParameter("@senderid", Session["sender"]);
SqlParameter param6 = new SqlParameter("@receiverid", Session["receiver"]);
DataSet ds = new DataSet();
ds = SqlHelper.ExecuteDataset(CommonSetting.GetConnectionString(true), CommandType.StoredProcedure, strSql, param5, param6);
dldisplayMessage.DataSource = ds;
dldisplayMessage.DataBind();
}
catch (Exception
ex)
{
Response.Write(ex.Message);
}
}
protected void Timer1_Tick(object sender, EventArgs e)
{
getMessage();
}
public void btnHistory_Click(object sender, EventArgs e)
{
try
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "scr", "javascript:OnClickHistory();", true);
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
//protected void btnFont_Click(object sender, EventArgs e)
//{
// Process p = new Process();
// p.StartInfo.FileName = "C:Users\\Lavanya\\Documents\\Visual Studio 2010\\Projects\\Window\\Bin\\debug\\Window.exe";
// p.Start();
//}
protected byte[] GetImage()
{
byte[] photo = new byte[FileUpload1.PostedFile.ContentLength];
FileUpload1.PostedFile.InputStream.Read(photo, 0, photo.Length);
return photo;
}
private void GetImages()
{
string sq = "select image from tbl_Emotions where EmotionName=@emotion";
string c = ":p";
SqlParameter sp2 = new SqlParameter("@emotion", c);
DataSet ds = new DataSet();
ds = SqlHelper.ExecuteDataset(CommonSetting.GetConnectionString(true), CommandType.Text,sq, sp2);
foreach (DataListItem dlv in dldisplayMessage.Items)
{
Image img;
img = (Image)dlv.FindControl("Image");
img.DataBind();
}
}
protected void btnEmotion_Click(object sender, EventArgs e)
{
byte[] OriginalPhoto = GetImage();
//Image img = new Image();
//img.ID = "image";
//img.ImageUrl = "images/smiley-1.png";
//string a = "images/smiley-1.png";
string b = ":p";
string sql = "sp_InsertEmotion";
SqlParameter sp1 = new SqlParameter("@image", OriginalPhoto);
SqlParameter sp2 = new SqlParameter("@emotionname", b);
DataSet ds = new DataSet();
ds = SqlHelper.ExecuteDataset(CommonSetting.GetConnectionString(true), CommandType.StoredProcedure, sql,sp1 ,sp2);
// dldisplayMessage.DataSource = ds;
// dldisplayMessage.DataBind();
}
}
Reply
Answers (
1
)
how to store smiley emotions in database in asp.net
please anyone give me the code for how to save data