0

Hi I am doing a social network service using asp.net/c#, I have little problems with message sending. Message are flowed top to bottom. Like this

But I want to display messages bottom to top Like facebook..

I am displaying messages using repeater control.

repeater control code

<asp:Repeater runat="server" ID="Repeater1">
 <ItemTemplate>     
     <div style="border-top: thin none #BBCEB3; border-bottom: thin none #BBCEB3; padding: 10px;  width: 548px; margin-top: 10px; right: 10px; left: 10px; border-left-width: thin; margin-left: 15px; background-color: #e9eaee; border-left-color: #BBCEB3; border-right-color: #BBCEB3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <br />
                    <div style="width: 58px; height: 40px">
                    <asp:Image ID="Image2" runat="server" Height="59px" ImageAlign="Top" ImageUrl="~/Profile/Image/Default.png" Width="55px" />
                        </div>
                    <div style="width: 307px;  margin-left: 65px; margin-top: -60px">
                        <asp:Label ID="Label6" runat="server" Font-Bold="True" Font-Names="Arial" ForeColor="#000066"><%#Eval("SenderID") %> </asp:Label>
                    </div>
                    <div id="status" style=" width: 461px; margin-left: 78px; margin-top: 11px;">&nbsp;<asp:Label ID="Label7" runat="server" Font-Italic="False" ForeColor="Black" Font-Size="Medium"><%#Eval("Messages") %> </asp:Label>
                    </div>
                    &nbsp;<div style="margin-left: 350px">
                        <asp:Label ID="Label11" runat="server"  Text="Posted on: " Font-Size="Small"><%#Eval("Time") %> </asp:Label>
                    </div>
                </div>

 </ItemTemplate>

Textbox code

<asp:TextBox ID="Message" runat="server" OnTextChanged="TextBox3_TextChanged" style="margin-left: 12px; text-align: left;" TextMode="MultiLine" Width="564px" Height="100px"></asp:TextBox>
Saddam Abu Ghaida
  • 6,381
  • 2
  • 22
  • 29

1 Answers1

0

The order of Items in the repeater will be the same as in DataSource, so just Order it by Time descending before bind.

Victor
  • 618
  • 4
  • 12
  • you are correct.it's works, now tell me How to create a scrollable Div Tag Vertically? – Softwares Aŋɖ Tricks Dec 30 '14 at 14:30
  • @SoftwaresAŋɖTricks look at the stack overflow's question http://stackoverflow.com/questions/9707397/making-a-div-vertically-scrollable-using-css – Victor Dec 30 '14 at 14:32
  • i did it also, and i have another problem, when i refresh it, it shows first message that i sent(therefore it scorlls to top when page is loading). but i want to show last message i sent when it page refresh.could you tell me how to do it? I think i need a load more older message function to stop that, but i don't know how to do it? – Softwares Aŋɖ Tricks Dec 30 '14 at 14:51
  • @SoftwaresAŋɖTricks your requirements is not so clear, however if you want bring some dynamic (live) actions like autoscroll or fetching data without users actions (e.g. by timer) you should look at what JavaSript can do for you – Victor Dec 30 '14 at 14:58
  • when i am starting to send message scroll display [like this](https://scontent-b-mxp.xx.fbcdn.net/hphotos-xpa1/v/t1.0-9/10906209_1507241386232104_79420700166337212_n.jpg?oh=bd971f020987357dcca17c94ac707564&oe=5536BC0B). when i press send message it shows old message [first and scroll is top](https://scontent-b-mxp.xx.fbcdn.net/hphotos-xap1/v/t1.0-9/10898054_1507241806232062_2461530347045754305_n.jpg?oh=44a103a5524a94e358275da237ab1d74&oe=55297972), but i want newer message – Softwares Aŋɖ Tricks Dec 30 '14 at 15:27
  • Div scrolls to top because of component/page is reloaded by browser, and for browser this is new content/page, to bring the context to the browser side at this point you could use JavaScript (e.g. $().scrollTo) to handle position of scroll on the page when page is ready (e.g. $(document).ready event) – Victor Dec 30 '14 at 15:42
  • actually i don't have big knowledge about javascript. could you can give me any code for that – Softwares Aŋɖ Tricks Dec 30 '14 at 15:47
  • It would be better to use search on StackOverflow or google.com – Victor Dec 30 '14 at 15:51
  • friend. can you edit this code by adding ajax, what should i do to add ajax, i didn't use ajax yet for this social network – Softwares Aŋɖ Tricks Dec 30 '14 at 15:57
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/67931/discussion-between-softwares-a-tricks-and-victor). – Softwares Aŋɖ Tricks Dec 30 '14 at 15:58