Recently wanted to consolidate the basic knowledge, so wrote a relatively easy to understand the practical message boards.
Some styles refer to csdn (seems to have been very hot recently), part of the source code reference Alexis.
Main structure:
1. Pre-preparation
2.repeater+aspnetpager pagination Effect
3.Ajax No Refresh message board, insert and delete messages
4. Custom Numbering
5. Summary
First on: (PS: Art is very general)
1. Pre-Preparation:
1. Database: Self-increment ID, user name, message content, user picture, message time.
2. Entity class: The field of the corresponding database
View Code
3. Data Access Layer:
View Code
2.repeater+aspnetpager pagination Effect
Always use repeater control, flexibility is high, but the previous pagination is their own handwriting, feeling more cumbersome. So I tried to use the Aspnetpager pagination control, the effect is quite good.
I will total the number of records, the number of items displayed per page, the current page index is declared public, is to insert data, JS Reference, in order to achieve automatic reverse arrangement of the function.
Front Code:
View Code
Background code:
View Code
3.Ajax No Refresh message board, add Delete message
Mainly through the general processing program ASHX processing the submitted data, and then according to their own needs to return data
There are two ways to delete a message: 1. Based on the ID returned by the lookup, this is what this article mentions. 2. According to the time to find the user's message, then perfect will do this.
JS Code:
View Code
General Handler code:
View Code
4. Custom Numbering
The main idea is to bind Aspnetpager the total number of records, the number of items displayed per page, the current page index to do some simple operation.
and the new insertion of the message number, the general is the same, is more than give a value num, each insertion is num++
Code:
<% #RowsCount-(PageNum-1) *pagesize-container.itemindex%>
5. Summary
This is the first to write a more complete blog, some places are not very clear. I usually have time to look at the blog Park, encounter interesting, they do not know how to grasp the knowledge point, a little reference, and then write module, consolidate the basic knowledge.
Personally think that even a simple message board, but can be varied according to the needs, if you constantly add some functions, to improve it, in fact, is to improve their ability.
Areas of general improvement:
1. Since there is no refresh message, there is no need to refresh the paging.
2. Consolidate JS knowledge, can do text box, data validation.
。。。。。。
SOURCE download
Transfer from-http://www.cnblogs.com/forevernome/archive/2011/12/25/2301366.html
Repeater+aspnetpager+ajax Message Board