Monday, March 26, 2012

Strange error

I am experimenting with sending data using the PreviousPage property. I have the "classic" example the first page where I take the data introduced by the client and send it, after some modifications where it is displayed, to the second page.
The problem is this piece of code which the compiler says is wrong even though it' s the same as in the example provided by Microsoft so that' s why I don' t understand the error :
In the first page
public String returnData()
{
get
{
return Label1.Text;
}
}
The error indicated is that "; expected".

Are you trying to define a property that can return (get) some data? Just remove the parenthesis like this:

public String returnData
{
get
{
return Label1.Text;
}
}


I removed and now I don' t get any errors on the first page, I get them on the second one:
public void PageLoad(...)
{
TestPage1 prev= TestPage1 as PreviousPage;
lbl.Text=prev.returnData; //lbl is a Label
}
The error Page doesn' t contain returnData method.

0 comments:

Post a Comment