聊天和状态更新编码,如FB [英] chat and status update coding like FB

查看:41
本文介绍了聊天和状态更新编码,如FB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友们,我尝试编写一个可以提供聊天选项的网站,还有状态更新

i有状态更新代码,一个多行文本框,一个文件上传和一个按钮,如果我们输入ant文本并发布它会显示但如果我发布ant图像比这个代码不起作用,我已经过了我所有的代码,请帮助我。

这是设计页面代码:



Dear Friends i am try to code a site which can provide the chating option, and also status update
i have code for status update one multi line textbox, one file upload and one button , if we enter ant text and post it will display but if i post ant image than this code will not work , i have past all my code here please help me .
This is the Design page code:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="LatestUpdates.ascx.cs" Inherits="Controls_Latest" %>
<style type="text/css">
    .styleLatestUpdates
    {
        width: 400px;
    }
    .stylePost
    {
        width: 98%;
        height: 90px;
    }
    .styleComment
    {
        width: 103px;
    }
    .stylePostPic
    {
        width: 110px;
        vertical-align: top;
    }
    </style>
<table style="width: 550px" align="center">
    <tr>
        <td align="left" style="padding-left: 10px">
            <asp:Label ID="lblName" runat="server" Font-Bold="True" Font-Names="Georgia" Font-Size="Large"></asp:Label>
        </td>
        <td align="right">
            <asp:LinkButton ID="btnAddAsFriend" runat="server" Text="Add As Friend" Font-Bold="True"

                Font-Italic="True" OnClick="btnAddAsFriend_Click"></asp:LinkButton>
            <br />
        </td>
    </tr>
</table>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <table align="center" cellpadding="0" cellspacing="0" class="styleLatestUpdates">
            <tr>
                <td>
                    <table style="width: 550px">
                        <tr>
                            <td align="left">
                                <panel runat="server" id="pnlStatus">
                                <asp:TextBox ID="txtWhatsOnYourHeart" runat="server" Height="59px" TextMode="MultiLine" Width="543px"></asp:TextBox>
                                <br />
                                 <asp:Button ID="btnPost" runat="server" BackColor="#CCCCCC" BorderColor="#CCCCCC" BorderStyle="Ridge" BorderWidth="1px" Font-Bold="True" ForeColor="#333333" OnClick="btnPost_Click"

                                    Text="Post" Width="52px" />
                                  <asp:FileUpload ID="FileUpload1" runat="server" />                                 <asp:UpdateProgress ID="ProgressBar" runat="server">
                                    <ProgressTemplate>
                                        <asp:Image ID="Image1" runat="server" ImageUrl="~/images/loading.gif" />
                                    </ProgressTemplate>
                                </asp:UpdateProgress>
                                </panel>
                            </td>
                        </tr>
                    </table>
                    <hr />
                </td>
            </tr>
            <tr>
                <td>
                    <asp:DataList ID="dlPosts" runat="server" Width="550px">
                        <ItemTemplate>
                            <div>
                                <table cellpadding="0" cellspacing="0" class="stylePost">
                                    <tr>
                                        <td class="stylePostPic" rowspan="2" align="center">
                                            <asp:ImageButton ID="YourPic" runat="server" BorderColor="Black" BorderStyle="Ridge"

                                                BorderWidth="1px" Height="60px" ImageUrl='<%# "ImageHandler.ashx?RegisterId="+ Eval("RegisterId") %>'

                                                Width="60px" OnClick="YourPic_Click" CommandArgument='<%#Bind("RegisterId") %>' />
                                        </td>
                                        <td valign="top" align="left">
                                            <asp:Label runat="server" ID="lblName" ForeColor="Blue" Font-Bold="True" Font-Italic="True">

                                            <%# DataBinder.Eval(Container.DataItem, "Name")%> &nbsp;Posted:</asp:Label>
                                             <div style="width: 300px">
                                                <%# DataBinder.Eval(Container.DataItem, "Post")%>
                                            </div>
                                            <div style="width:300px">
                                                <%#DataBinder.Eval(Container.DataItem,"img") %>
                                            </div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="right" valign="bottom">
                                            <asp:Label runat="server" ID="lblPostedOn" ForeColor="Black" Font-Italic="True" Font-Size="Small">

                                            Posted On: <%# DataBinder.Eval(Container.DataItem, "PostDate")%>


                                            </asp:Label>
                                        </td>
                                    </tr>
                                </table>
                                <br />
                                <hr />
                            </div>
                        </ItemTemplate>
                    </asp:DataList>
                </td>
            </tr>
        </table>
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="btnPost" EventName="Click" />
    </Triggers>
</asp:UpdatePanel>







This is the logical post button code :






This is the logical post button code :

String ss, ss1;
  protected void btnPost_Click(object sender, EventArgs e)
  {
      //if (FileUpload1.HasFile)
      //{
         // ss = Server.MapPath("img");
          //ss = ss+"/" +FileUpload1.FileName;
          ss1 = "~\\img\\" + FileUpload1.FileName.ToString();
          FileUpload1.PostedFile.SaveAs(Server.MapPath(ss1));

          string PostDate = DateTime.Now.ToLongDateString();
          string InsertPostquery = "Insert into Posts (Post,FromId,ToId,PostDate,img) values('" + txtWhatsOnYourHeart.Text + "','" + Convert.ToInt32(Session["UserId"]) + "','" + Convert.ToInt32(Session["CurrentProfileId"]) + "','" + PostDate + "','" + ss1 + "')";
          Database.InsertData(InsertPostquery);
          LatestUpdates();
          txtWhatsOnYourHeart.Text = string.Empty;
      //}
      //else
      //{
      //    string PostDate = DateTime.Now.ToLongDateString();
      //    string InsertPostquery = "Insert into Posts (Post,FromId,ToId,PostDate,img)values('" + txtWhatsOnYourHeart.Text + "','" + Convert.ToInt32(Session["UserId"]) + "','" + Convert.ToInt32(Session["CurrentProfileId"]) + "','" + PostDate + "','" + ss1 + "')";
      //    Database.InsertData(InsertPostquery);
      //    LatestUpdates();
      //    txtWhatsOnYourHeart.Text = string.Empty;
      // }
  }

推荐答案

这篇关于聊天和状态更新编码,如FB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆