|
-
May 15th, 2013, 02:09 AM
#1
Thread Starter
Member
Pagination sample, somebody can help me??
Hi
I've been doing a Pagination Sample, and when to run it in the browser I get the following
http://localhost/example/?=2 or http://localhost/example/?=9
This is the code I'm doing
Code:
Protected Function DisplayPaging(ByVal index As Integer) As String
If (PagedData.CurrentPageIndex + 1) = index Then
PagingCont += "<b> " + index.ToString() + " </b>"
Else
PagingCont += " <a href=""" + Request.CurrentExecutionFilePath + "?=" & index.ToString() & """>" + index.ToString() + "</a> "
End If
Return PagingCont
End Function
Protected Sub btFirst_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs)
Response.Redirect(Request.CurrentExecutionFilePath & "?=1")
End Sub
Protected Sub btPrevious_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs)
Response.Redirect(Request.CurrentExecutionFilePath & "?=" & (PagedData.CurrentPageIndex))
End Sub
Protected Sub btNext_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs)
Response.Redirect(Request.CurrentExecutionFilePath & "?=" & (PagedData.CurrentPageIndex + 2))
End Sub
Protected Sub btLast_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs)
Response.Redirect(Request.CurrentExecutionFilePath & "?=" & (PagedData.PageCount))
End Sub
my question is, how I can make it for me then appears in the browser
http://localhost/example/2 or http://localhost/example/9
???
-
May 15th, 2013, 03:01 AM
#2
Re: Pagination sample, somebody can help me??
Moved to the ASP.Net forum
-
May 15th, 2013, 08:26 AM
#3
Re: Pagination sample, somebody can help me??
Hey,
Out of interest which sample are you doing?
Based on the query string format that you are using, I would have thought that you needed something like this:
http://localhost/example/?page=9
i.e. to actually name the QueryString parameter, and inspect that when the page loads.
Once you have that in place, you can then look to use ASP.Net URL Routing to make the url's "prettier". You can find a walkthrough of doing this here:
http://msdn.microsoft.com/en-us/libr...v=vs.100).aspx
Hope that helps!
Gary
-
May 18th, 2013, 12:00 AM
#4
Thread Starter
Member
Re: Pagination sample, somebody can help me??
Gary thanks for your answer 
and now is the first time I use Routing in a Web Forms, and my questions is
1. what am I doing wrong in the line of PagingCont += " <a href=""" + Page.RouteData.Values("Name") + """>" + index.ToString() + "</a> " because dont work 
Code:
Protected Function DisplayPaging(ByVal index As Integer) As String
If (PagedData.CurrentPageIndex + 1) = index Then
PagingCont += "<b> " + index.ToString() + " </b>"
Else
PagingCont += " <a href=""" + Page.RouteData.Values("Name") + """>" + index.ToString() + "</a> "
'PagingCont += " <a href=""" + Request.CurrentExecutionFilePath + "?page=" & index.ToString() & """>" + index.ToString() + "</a> "
End If
Return PagingCont
End Function
global.asax
Code:
RouteTable.Routes.MapPageRoute("exam", "example/{Name}", "~/example/default.aspx")
2 .What do I need to replace this line and work with System.Web.Routing?
Response.Redirect(Request.CurrentExecutionFilePath & "?page=1")
Response.Redirect(Request.CurrentExecutionFilePath & "?page=" & (PagedData.CurrentPageIndex))
Response.Redirect(Request.CurrentExecutionFilePath & "?page=" & (PagedData.CurrentPageIndex + 2))
Response.Redirect(Request.CurrentExecutionFilePath & "?page=" & (PagedData.PageCount))
as I say is first time I use Routing.
-
May 18th, 2013, 09:57 AM
#5
Re: Pagination sample, somebody can help me??
 Originally Posted by Dr-Delta
1. what am I doing wrong in the line of PagingCont += " <a href=""" + Page.RouteData.Values("Name") + """>" + index.ToString() + "</a> " because dont work 
Can you be a little bit more specific? What exactly isn't working?
 Originally Posted by Dr-Delta
2 .What do I need to replace this line and work with System.Web.Routing?
Should would replace it with the routed url.
i.e. you said you wanted your URL to be pretty, so you would want to redirect to something like http://localhost/example/9
Where the ASP.Net Routing would take the value of 9, and put it into the right place, placed on the route that you have set up.
Gary
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|