C# - Ajax Postback Pager - Obtain The Correct Pagenumber?
Sep 13, 2010
I have a 'shop' page, where all the items in the shop is listed. I have a sortingfunction, to decide how many results pr. page I want to see. I also have a pager. The pager is built with two buttons (a Previous- and Next-pagebutton), and a textbox which shows the pagenumber. The pager is on both the top, and bottom of the page. When I change the text in the textbox, the following code fires:
protected void tbPageNumberTop_TextChanged(object sender, EventArgs e)
{
tbPageNumberBottom.Text = tbPageNumberTop.Text;
updpanMain.Update();
}
This causes a pageload, where I get the number from the textbox, and parse it to an integer, which I can use to dynamically create an SQL request. This works just perfectly. Here's my problem. When I click the "Next" button or "Previous" button, the text in the textbox changes, but when I get the number from the textbox, I get the value of the textbox as it was BEFORE the button was clicked. How do I obtain the correct pagenumber? Here's my Click-code:
protected void btnNextPage_Click(object sender, EventArgs e)
{
int PageNumber = Convert.ToInt32(tbPageNumberTop.Text);
PageNumber += 1;
tbPageNumberTop.Text = PageNumber.ToString();
tbPageNumberBottom.Text = PageNumber.ToString();
updpanMain.Update();
}
protected void btnPrevPage_Click(object sender, EventArgs e)
{
int PageNumber = Convert.ToInt32(tbPageNumberTop.Text);
PageNumber -= 1;
tbPageNumberTop.Text = PageNumber.ToString();
tbPageNumberBottom.Text = PageNumber.ToString();
updpanMain.Update();
}
And here's what happens on page_load
if (!this.IsPostBack)
{
intStartPosition = 0;
intPageNumber = 1;
tbPageNumberBottom.Text = intPageNumber.ToString();
tbPageNumberTop.Text = intPageNumber.ToString();
}
if (tbPageNumberTop.Text != "1" || tbPageNumberBottom.Text != "1")
{
intPageNumber = Convert.ToInt32(tbPageNumberTop.Text);
}
else
{
intPageNumber = 1;
}
intStartPosition = (intPageNumber * intItemsPrPage) - intItemsPrPage;
strResultsPrPage = intItemsPrPage.ToString();
intStartPosition represents the first LIMIT integer in my SQL string, and strResultsPrPage represents the second integer, i.e. LIMIT 100, 500 is showing results from 500 to 600. (Page 5, with 100 results per page)
View 2 Replies
Similar Messages:
Jan 30, 2011
suggest any jQuery/Ajax pager solution for asp.net mvc application.
Main requirements are:
1) source code available ( will modify a little if necessary)
2) page shifting have to be without full postbacks based on jQuery/Ajax
BTW, what pager code has Stackoverflow?
View 1 Replies
Jul 19, 2010
title says all. I guess we all get into situation like this one on daily basis. Pager as UI is useless if there is less than PageSize items in DataObject binded to ListView or other types of Dababindable objects.
View 1 Replies
Nov 22, 2010
I am using tabs and I want some user input on each one.hen I click submit I return the partial view. However it is only the partial view that gets rendered.What I am trying to do is keep the overall view and render the partial view. In fact what I am trying to do is known as hijaxing, but I am not familiar enough with Ajax that I know how to do it.So this is my view;
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Employee.Master" Inherits="System.Web.Mvc.ViewPage<SHP.WebUI.Models.HolidayRequestViewModel>" %><asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> HolidayRequest</asp:Content><asp:Content
ID="Content2" ContentPlaceHolderID="EmployeeContent" runat="server"> <% using (Html.BeginForm()) {%> <%: Html.AntiForgeryToken() %> <h2>Holiday Request</h2> <p>You have <%: Html.DisplayFor(model => model.DaysAvailableThisYear) %> days left annual leave for this year and <%: Html.DisplayFor(model => model.DaysAvailableNextYear) %> days left for next year.</p> <p>If your request is approved and exceeds the number of days left, then those extra days will not be paid.</p> <%: Html.HiddenFor(x => x.EmployeeId) %><%: Html.HiddenFor(x => x.ApproverId) %> <% } %> <div id="tabs"> <ul> <li><a href="#tabs-1">Approver</a></li> <li><a href="#tabs-2">Single Date</a></li> <li><a href="#tabs-3">Date Range</a></li> </ul> <div id="tabs-1"> <% Html.RenderPartial("GetApproverTab", Model); %> </div> <div id="tabs-2"> <% Html.RenderPartial("GetSingleDateTab", Model); %> </div> <div id="tabs-3"> <% Html.RenderPartial("GetDateRangeTab", Model); %> </div> </div></asp:Content>
This is my partial view;
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<SHP.WebUI.Models.HolidayRequestViewModel>" %><% using (Html.BeginForm("GetSingleDateTab", "Employee", FormMethod.Post, new { id = "frmSingleDate" })) { %><p>Enter your day or part day of Annual Leave here.</p><table> <tr> <td align="right">Date:</td> <td><%: Html.EditorFor(x => x.SingleDate) %></td> </tr> <tr> <td align="right">Morning Only:</td> <td><%: Html.CheckBoxFor(x => x.MorningOnlyFlag) %></td> </tr> <tr> <td align="right">Afternoon Only:</td> <td><%: Html.CheckBoxFor(x => x.MorningOnlyFlag) %></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" value="Save" /></td> </tr></table><%: Html.HiddenFor(x => x.EmployeeId) %><%: Html.HiddenFor(x => x.ApproverId) %> <% } %>
and this is my controller;
View 7 Replies
Oct 27, 2010
I've watched the Slideshow videos and created a number of examples that run fine. The code I've attached at the bottom is the smallest one, but instead of hard coding the image locations, I would like to select the slides from either of the following statements, which return the top 5 images selected randomly from our floorplans database.
<asp:AccessDataSource id="AccessDataSource1" runat="server" DataFile="../fpdb/J3_2005.mdb" SelectCommand="SELECT TOP 5 [Elev_Pimage] FROM [PLANS_Active] ORDER BY RND(INT(NOW*[SF_Total])-NOW*[SF_Total])" />
or,
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:J3_2005Slideshow %>" ProviderName="<%$ ConnectionStrings:J3_2005Slideshow.ProviderName %>" SelectCommand="SELECT TOP 5 [Elev_Pimage] FROM [PLANS_Active] ORDER
BY RND(INT(NOW*[SF_Total])-NOW*[SF_Total])" />
<title>SlideShow</title>
View 9 Replies
Jun 23, 2010
I have some textboxes (in an UpdatePanel in a ModalPopup in a User Control) that look like this:
<asp:TextBox ID="exampleTextBox" runat="server" MaxLength="10"
CssClass="datepicker" ReadOnly=true
Text='<%# Bind("ExampleDateField") %>' Width="77px">
</asp:TextBox>
I also have some jQuery (imported from file on the Master page) that hooks up the jQuery DatePickers like so:
function pageLoad() {
$(".datepicker").unbind();
$(".datepicker").datepicker({
changeMonth: true,
changeYear: true,
showOtherMonths: true,
selectOtherMonths: true,
beforeShowDay: $.datepicker.noWeekends,
showOn: 'button',
buttonImage: '../Resources/Images/Calendar_scheduleHS.gif',
buttonImageOnly: true,
buttonText: 'Select a Date'
});
}
The DatePickers appear correctly, even after a postback. The problem is that the value of the textboxes is not changed when a postback occurs. This is very odd since the textbox shows the selected date in the browser. However, the value of the textbox is still the date that the textbox originally had, not the date selected from the datepicker.
View 1 Replies
Jun 27, 2010
I want to create an ajax panel (correct terminology?) in my webpage that updates just part of the page instead of updating the whole page.Can I do this while using ASP.net and Visual Basic.net? I do not use C#.If this is possible using VB.net, can someone point me to a few documents that will help me get started?
On a 1 to 10 scale, I would rate my technical knowledge at only about 5 or 6.
View 3 Replies
Feb 10, 2010
I am doing a workshop , it has questions, and answers with radiobuttons, I need that when a click is made on a radiobutton a message appears saying that it is correct or it is not correct, how can a do it,
View 10 Replies
Mar 6, 2011
I am using 3 tables and are trying to get the correct info belonging to the correct id. Like this: I go to a page and here i want to see the information from the 3 tables using a specific id.
I have written this so far in a query:
[Code]....
My problem is that the last line does not work and i am uncertain how to make this work? How to write it correctly that is.
View 2 Replies
Oct 15, 2010
When an asynchronous postback happened inside update panel, another postback happens also for MasterPagenot only update panel embedded page .I want to prevent this MasterPage postback . is this possible ?think like i have a MasterPage and another page which is test.aspx which is content page of MasterPagei have update panel at test.aspxwhen asynchronous postback happens at this test.aspx update panel it also loads
MasterPage Page_Loadi want to prevent this (it should not also load MasterPage Page_Load)
View 3 Replies
Jan 28, 2010
I have an AJAX TabContainer. Each tab I have a ValidationSummary control with different ValidationGroup name for each tab. The problem is, now nothing show sup in the ValidationGroup when q required field is blank. The web form won't get submit but there is nothing displaying on the page either. All the RequiredFieldValidator are not showing in the web form either. All the RequiredFieldValidator controls are set to use the correct ValidationGroup too.
View 9 Replies
Mar 5, 2010
What's the correct way to use a multiview with ajax updatepanel?I've searched about this and people said to use the structure
View 2 Replies
Mar 25, 2010
I have a form that contain many field must filled.
I use Asp Required validator and ajax validator callout to make a cool error message.
I put that form into box which have scrollbar. (Not IE Scrollbar)
Running the application then try to scroll the form with that scrollbar.
Then pressing the button to trigger the validator required.
Finally the message is displayed but the message is not in correct position. It is above suppose to be.
View 2 Replies
May 3, 2010
I have a grid/table that is pretty big in width. The AutoCompleteExtender is outside the right side of the page and the user needs to scroll to view it. When you scroll over and start using it, the drop down list with the values are displayed back to the left in the original viewable portion of the page.
View 1 Replies
Dec 1, 2010
I am using ASP.NET3.5. I have used MaskedEditExtender for currency purpose. when iam insering data into table it is accepting correct figures. while reading the same figures from database,I am displaying the figured in another textbox. (for second textbox i have used MaskedEditExtender) but it is displaying in that text box wrongly. suppose x=100 am reading this value from database and displaying x value in edit mode.but it is displaying 1.00. means it is taking last 2 digits as decimal points. how can I show in correct format?
View 5 Replies
Jun 14, 2010
We have upgraded recently from Visual Studio 2008 to Visual Studio 2010. One of the upgrades has to do with the AJAX libraries.
On the initial project (SV2008) the AjaxControlToolkit.dll used was:
Product Version:version: 1.0.10920.0
Date Modified: 28/09/2007
The current one, used in the VS2010 project is:
Product Version:
3.0.31106.0
Date Modified: 09/03/2010
The project compiles fine but once we access some web pages, we get numerous error messages with the first one being:
Message: AjaxControlToolkit requires ASP.NET Ajax 4.0 scripts. Ensure the correct version of the scripts are referenced. If you are using an ASP.NET ScriptManager, switch to the AjaxScriptManager in System.Web.Ajax.dll, or use the ToolkitScriptManager in AjaxControlToolkit.dll.
View 8 Replies
May 20, 2010
i am getting js runtime error
my page has update panel and on dropdown selected change page get refresh..
but for one selection i am getting this error
Sys.WebForms.PageRequestManagerServerErrorException: Input string was not in a correct format.
[URL]
ScriptResource.axd is a file dynamically genrated by resource manager so using firbug and idev tool i tried to debug but couldn't..
View 3 Replies
May 7, 2015
I have 3 table in database
1-state
Id state
1 USA
2 UK
2-City
Id name state
1 Canada USA
2 London UK
3-Region
Id regionname cityid
1 01 Canada
2 02 London
and I have 3 DropDownList that refer below thread [URL] ...
I use cascadingdropdown for these 3 dropdownlist below are codes:
AND
[WebMethod]
public CascadingDropDownNameValue[] GetCountries(string knownCategoryValues)
{
string query = "SELECT state FROM stateTest";
List countries = GetData(query);
return countries.ToArray();
}
[Code] ....
1-DDLstate
2-DDLcity
3-DDLregion
at first I should select Item from DDLsate then DDlcity and at the end I should select Item from DDLregion
above code work correctly for ddlstate and ddlcity but it doesn't work for ddlregion...
I mean when I select Item from ddlcity in ddlregion shows:[Metod error500]
View 1 Replies
Mar 3, 2010
I have found a problem with the Masked Edit Extender when using it with a culture of Azeri (Latin, az-Latn-AZ). I have not found anywhere that states that the control should not be used with languages that is not included in the list of languages that the ajax control toolkit is translated.
The currency symbol for Azeri is "man." the first problem is that the mask displays this as "man," but the comma is the decimal indicator for Azeri.
Scenario 1
When the DisplayMoney property is set to "right" and the currency is removed by the masked editors script the resulting value looks something like "12,12," the second comma then invalidates the numeric value and all my compare validator which also acts on the same textbox keeps failing because the value is not numeric.
Scenario 2:
When the DisplayMoney property is set to "left" there is always a "0," added to the string because the the script of the masked editor removes the man then gets to the comma (man",") sees it as a decimal indicator and adds the 0 before the comma this happens on the first blur of the textbox each resulting onblur event will add another 0 to the value. But the value is already invalidated by the fact that it again has two commas like 0,12,12.
I get this result even with the Ajaxcontroltoolkit sample site, the changes needed to sample site's MaskedEdit.aspx page can be seen below.
For scenario 1, change the first MaskedEditExtender on the MaskedEdit.aspx page to the following:
[Code]....
For scenario 2 effect change the first MaskedEditExtender on the MaskedEdit.aspx page to the following:
<ajaxToolkit:MaskedEditExtender ID="MaskedEditExtender2" runat="server"
View 3 Replies
Oct 16, 2010
[Code]....
This works, but I would like to obtain further information Year. Currently only displays a number. How to include the year in txtStevilka.Text?
View 2 Replies
Mar 10, 2011
Is there a build in library in .NET that can compute secure one-way hash ? I mean a library that implements SHA-2 cryptographic hash function or something similar.
If is there is no SHA-2 implementation some weaker hash funcion would be sufficient. If there are more options I prefer the most secure one.
provide a use example e.g. provide the code that returns one-way hash for string mySampleString.
View 3 Replies
May 29, 2010
I am using MVC 2 right out of the box, and the control gives the login and seems to work wonderfully. Now I am trying to find out the userId of the person who is logged in, so that i can retrieve information that is only needed for that one person. How do i find out how is logged in?
View 2 Replies
Aug 6, 2010
i'm a beginner web programmer. I've been coding desktop applications primarily. Right now, i have created this web app, in Silverlight, that uses a web service of my own for querying the database. The thing is, one of the app functionalities is the ability to open PDF files. I know that silverlight won't let you do this, but using an IFrame on top of the silverlight application you are able to display a page with de pdf file (using acrobat plug in). So here's the problem, my silverlight app passes the pdf path to the web service and, in return, the web service would create a new Page and pass the new page URI back so that it can be displayed on the IFrame:
[Code]....
View 1 Replies
Jul 1, 2010
What is the best way to get the value of a dropdownlist control before it has been changed and after it has been changed. Can it be done in one routine? In other words, if a user clicks on a dropdownlist control and changes it's value, I need to get the old value and the new value and send both these values as input parameters to a stored proc.
View 3 Replies
Mar 30, 2010
I have a website with server-side code that needs to determine the physical path of the website on disk from the sites url...
Example 1: Given www.mysite.com, how can I determine the physical directory it is mapped to?
Example 2: Given dev.mysite.com, again, how can I determine it's physical directory?
View 3 Replies