Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Need to create a full server custom control that is able to do paging

Posted on 2007-11-20
2
Medium Priority
?
163 Views
Last Modified: 2013-11-07
Hi, I am totally new to this stuff, and I would like to know how to create a full custom web server control that allows me to do paging (set number of lines per page, get number of all pages, and to know the current page I am at)

The content that would be display would come from a array(list).

Any idea on doing that? I only know how to do the REALLY basic stuffs and I have no idea where to start.
0
Comment
Question by:Sharalynn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 12

Accepted Solution

by:
Munawar Hussain earned 1500 total points
ID: 20325563
here is full paging contol with complete details and working example
This one seems neat as its generic can be used with any control
http://www.codeproject.com/aspnet/paginguc.asp

for reference here are other examples with samples..
http://www.freevbcode.com/ShowCode.asp?ID=5574
http://www.15seconds.com/issue/030812.htm

thanks
0
 

Author Comment

by:Sharalynn
ID: 20325981
The articles don't really code them inside the web control itself.

See attached code snippet. Am I in the correct direction? How should I continue?

Also, I need to raise the PageChange event whenever the next/prev buttons are clicked, so that it can provide information on the line count of the last sentence on the current page with the e parameter.

Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Text
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Drawing
 
<DefaultProperty("Text"), ToolboxData("<{0}:PageListBox1 runat=server></{0}:PageListBox1>")> _
Public Class PagedListBox
    Inherits WebControl
    Implements IPostBackEventHandler
 
    Private mLinesPerPage As Short
    Private mNumberOfPages As Short
    Private mCurrentPage As Short
    Private mStoreArray As Array
 
    Public Event PageChange()
 
    Public Property LinesPerPage() As Short
        Get
            Return mLinesPerPage
        End Get
        Set(ByVal value As Short)
            mLinesPerPage = value
        End Set
    End Property
 
    Public Property NumberOfPages() As Short
        Get
            Return mNumberOfPages
        End Get
        Set(ByVal value As Short)
            mNumberOfPages = value
        End Set
    End Property
 
    Public Property CurrentPage() As Short
        Get
            Return mCurrentPage
        End Get
        Set(ByVal value As Short)
            mCurrentPage = value
        End Set
    End Property
 
    Public Property StoreArray() As Array
        Get
            Return mStoreArray
        End Get
        Set(ByVal value As Array)
            mStoreArray = value
        End Set
    End Property
 
    '<Bindable(True), Category("Appearance"), DefaultValue(""), Localizable(True)> Property Text() As String
    '    Get
    '        Dim s As String = CStr(ViewState("Text"))
    '        If s Is Nothing Then
    '            Return String.Empty
    '        Else
    '            Return s
    '        End If
    '    End Get
 
    '    Set(ByVal Value As String)
    '        ViewState("Text") = Value
    '    End Set
    'End Property
 
    '<Bindable(True), Browsable(True)> _
    'Public Property DataSource() As IEnumerable
    '    Get
    '        Return _datasource
    '    End Get
    '    Set(ByVal value As IEnumerable)
    '        _datasource = value
    '    End Set
    'End Property
 
    'Private Sub CreateArrayList()
    '    Dim dataSource As IEnumerable = Nothing
    '    Try
    '        dataSource = Me._datasource
    '    Catch ex As Exception
 
    '    End Try
 
    '    If Not (dataSource Is Nothing) Then
    '        Dim dataObject As Object
 
    '        For Each dataObject In dataSource
    '            datalist.Add(dataObject)
    '        Next
    '        datalist.TrimToSize()
    '    End If
    'End Sub
 
    'Protected Overrides Sub DataBind(ByVal raiseOnDataBinding As Boolean)
    '    MyBase.DataBind(raiseOnDataBinding)
    '    MyBase.OnDataBinding(EventArgs.Empty)
 
    '    Controls.Clear()
    '    If HasChildViewState() Then
    '        ClearChildViewState()
    '    End If
 
    '    ChildControlsCreated = True
 
    '    If Not IsTrackingViewState() Then
    '        TrackViewState()
    '    End If
 
    '    CreateArrayList()
    'End Sub
 
    Protected Overrides Sub RenderContents(ByVal output As HtmlTextWriter)
        output.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0")
        output.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0")
        output.AddAttribute(HtmlTextWriterAttribute.Border, "1")
        output.AddAttribute(HtmlTextWriterAttribute.Width, "50%")
        output.AddStyleAttribute(HtmlTextWriterStyle.BorderColor, Color.Red.Name)
 
        output.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "1", False)
        output.RenderBeginTag(HtmlTextWriterTag.Table)
        output.RenderBeginTag(HtmlTextWriterTag.Tr)
        output.RenderBeginTag(HtmlTextWriterTag.Td)
        output.RenderBeginTag(HtmlTextWriterTag.Button)
        output.Write("Next")
        output.RenderEndTag()
        output.RenderBeginTag(HtmlTextWriterTag.Td)
        output.Write("&nbsp;&nbsp;&nbsp;&nbsp;")
        output.RenderEndTag()
        output.RenderBeginTag(HtmlTextWriterTag.Td)
        output.RenderBeginTag(HtmlTextWriterTag.Button)
        output.Write("Previous")
        output.RenderEndTag()
        output.RenderEndTag()
        Dim i As Short
        For i = 0 To StoreArray.Length - 1
            output.RenderBeginTag(HtmlTextWriterTag.Tr)
            output.RenderBeginTag(HtmlTextWriterTag.Td)
            output.Write(StoreArray(i))
            output.RenderEndTag()
            output.RenderEndTag()
        Next
        output.RenderEndTag()
    End Sub
 
    Public Sub RaisePostBackEvent(ByVal eventArgument As String) Implements System.Web.UI.IPostBackEventHandler.RaisePostBackEvent
 
    End Sub
End Class

Open in new window

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question