|
Ya,I'm really sorry, It wont work.
Try this in your page load
if(this.PageNumber ==1)
lnkPrevious.Enabled = false;
else
lnkPrevious.Enabled = true;
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
|
|
|
|
|
its working.
Thanks a lot...
|
|
|
|
|
i have one problem..
iam getting error .plz guide me .
public partial class PagerControl : System.Web.UI.UserControl
{
private int _pageNumber;
public int PageNumber
{
set
{
_pageNumber = value;
ViewState["PageNumber"] = value;
}
get
{
return int.Parse(ViewState["PageNumber"].ToString());
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (this.PageNumber == 1)
{
lnkPrevious.Enabled = false;
}
else
{
lnkPrevious.Enabled = true;
}
if (this.PageNumber == 11)
{
lnkNext.Enabled = false;
}
else
{
lnkNext.Enabled = true;
}
}
Server Error in '/ucnew' Application.
--------------------------------------------------------------------------------
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 22: get
Line 23: {
Line 24: return int.Parse(ViewState["PageNumber"].ToString());
Line 25: }
Line 26: }
|
|
|
|
|
problem is :
You are calling PageNumber in this line ---> if (this.PageNumber == 1) before you have set the value. So you are getting that error. Set the value first then you must do a get.
To Fix this:
Write a contructor of your class and inside the constructor set the value of _pageNumber = 1 or 0 as per your requirement.
sample code here!!!
public PagerControl()
{
_pageNumber = 1;
}
Thanks,
Arindam D Tewary
|
|
|
|
|
Hi arindam ..
i didnt get .
plz guide me in code level ..
|
|
|
|
|
i did'nt get.
plz tell me clearly..
|
|
|
|
|
Just copy the code part I have given !!
public PagerControl()
{
_pageNumber = 1;
}
after this line .
public partial class PagerControl : System.Web.UI.UserControl
{
private int _pageNumber;
So that it looks like:
public partial class PagerControl : System.Web.UI.UserControl
{
private int _pageNumber;
public PagerControl()
{
_pageNumber = 1;
}
Thanks,
Arindam D Tewary
|
|
|
|
|
ITS GIVING A ERROR ,
class,structs,interface method must have a return type.
|
|
|
|
|
it looks like the viewstate page number has not been created yet which is why its showing an object refrerence error as yoiu arent referencing anything!
|
|
|
|
|
kathyani wrote: if (this.PageNumber == 1)
{
You are retrieving the PageNumber before setting it.So
kathyani wrote: return int.Parse(ViewState["PageNumber"].ToString());
Will be null.
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
|
|
|
|
|
|
Are you using the user control in all of your 11 pages?
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
|
|
|
|
|
yes , iam using all 11 pages
|
|
|
|
|
Why can't you set the pagenumber property at the design time itself(for the user control).I mean In the 11 pages.
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
|
|
|
|
|
i took the previous ,next link buttons and 11 link buttons .
where i have to put pagenumber property ?
|
|
|
|
|
which one i have to put ?
pagenumber =11 (everypage)
or
page1.aspx ,pagenumber =1 ???
|
|
|
|
|
In each page corresponding page number!
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
|
|
|
|
|
Before i put the pageload .now i need to add .asp properties also??
pagercontrol.pagenumber=1
2ND PAGE
PAGERCONTROL1.PAGENUMBER=2
THANK U..
|
|
|
|
|
Add the following code to your user control Page Load, Before 'if'.
<br />
if(ViewState["PageNumber"]==null)<br />
ViewState["PageNumber"]="1";
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
|
|
|
|
|
its giving error sir.
i wrote code ..
public partial class PagerControl : System.Web.UI.UserControl
{
private int _pageNumber;
public int PageNumber
{
set
{
_pageNumber = value;
ViewState["pageNumber"] = value;
}
get
{
return int.Parse(ViewState["PageNumber"].ToString());
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (ViewState["pageNumber"] == null)
ViewState["pageNumber"] = "1";
if (this.PageNumber == 1)
{
lnkPrevious.Enabled = false;
}
else
{
lnkPrevious.Enabled = true;
}
if (this.PageNumber == 11)
{
lnkNext.Enabled = false;
}
else
{
lnkNext.Enabled = true;
}
}
|
|
|
|
|
What the same error?
PS is this the longest run for a post ever?
|
|
|
|
|
i put the code in forums ,once look it the code .
|
|
|
|
|
.netman wrote: is this the longest run for a post ever?
Not even close. You need to up it by an order of magnitude.
|
|
|
|
|
I think Its over
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
|
|
|
|
|
kathyani wrote: ViewState["pageNumber"] = value;
kathyani wrote: return int.Parse(ViewState["PageNumber"].ToString());
kathyani wrote: f (ViewState["pageNumber"] == null)
ViewState["pageNumber"] = "1";
PageNumber or pageNumber???
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
|
|
|
|