|
Rough1 myRough;
myRough = (Rough1)PreviousPage;
txtName.Text = myRough.myName;
Line 2 would throw if it failed, so I assumed txtName is null. Where are you calling this code and where does txtName come from ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Actually i've two textbox named "txtName"
first textbox bringing the name from the Page1 through the property named "myName" and second textbox which is also showing the name entered in the first textbox.........................
even i've mentioned all my code in my first request
|
|
|
|
|
you need to buy a book on C# and one on ASP.NET. You plainly do not realise that where you call your code, can make a difference. It can.
The issue is, the control is null. If you don't want to work with us to work out why, then we can't help you
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
.NET- India wrote: but it's throwing an error "Object reference not set to an instance of an object"
You can also get previous page's control value by using findcontrol method.
You need not use property.
for example
txtName.Text = ((TextBox)PreviousPage.FindControl("txtName")).Text;
Regard
Imran Khan
please don't forget to vote on the post that helped you.
|
|
|
|
|
Yeah, but FindControl is a hack, surely ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
|
Because he told you another way to do the same thing. What's needed here is more detail so we can see what you're doing here that causes this not to work. I think that your textbox variable is null, now we need to work out why. In general, you should use the debugger before asking here, then you'd have this sort of detail to give us from the start, or maybe even solve your own problem
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
yes sir it's not brining the value from Page1 but i'm transferring the value so what should i do know
|
|
|
|
|
Have you used PostBackUrl event on page1 to post back from page1 to page2?
Regard
Imran Khan
please don't forget to vote on the post that helped you.
|
|
|
|
|
if i use PostBackUrl in page1 then it works fine but if i dont use then it throws the error..............
But if i've to take the value from a textbox given in a User Control then how i will get the value thereof
|
|
|
|
|
.NET- India wrote: if i use PostBackUrl in page1 then it works fine but if i dont use then it throws the error..............
If you don't use that property, then how do you hope to do a cross page postback ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
You should set a breakpoint, work out which variable is null, then work out why
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
hai friends
my project is for "Real Estate " bussiness
my comapany has branches in two different cities
project database is maintained by these two branches
now to gather/obtain data from these database
and combine them and next fill in grid view
this is my requirement....
thanks in advance
vijay
|
|
|
|
|
So, your problem is that you need to merge data from two DBs into one grid, or is it just that you don't know how to use SQL or ASP.NET ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi vijay.
May i know where studied your 10th class( Is in Port High School at Vizag).
|
|
|
|
|
So, either you are looking for someone to do you college project for you, or you have blagged your way into a job where you have no idea what you are doing.
Either way, it would be better for you to try first and then ask specific questions when things go wrong.
(The alternative is to pay someone to do the work properly)
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Hi,
I placed a LinkButton on MasterPage. Made visibility to False.
I wrote a property to set its visibility
public bool Lbtn_Property
{
get{ return Lbtn1.Visible; }
set{ Lbtn1.Visible=value; }
}
----------------------------------
In Page2.aspx
button_Click()
{
Default_Master obj=new Default_Master();
obj.Lbtn_Property=True;
Response.Redirect("Page3.aspx");
}
Its not working.. When page Loads after button click LinkButton is still invisible.
I could able to set property Locally.
But want that property to be static(i.e, Permanent untill we change it again).
So i Made that property as
Publi static bool Lbtn_Property
{
get{}
set{}
}
But it raising compile time exception :An object reference is required for the non static field,method or a property 'Default_Master.Lbtn1'
Please help me,
Thanks in advance.
|
|
|
|
|
You can't make it static, because it's returning a property on a non static object. You can cast the Master property to be of your type of master page and access it's properties. I'd make such a property available via a base class so you can always access it.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks for your reply.
But i couldn't understand properly.
Can you please reply me in detail.
Thanks & Regards
sekhar
|
|
|
|
|
You should buy a C# book and read it.
"An object reference is required for the non static field,method or a property 'Default_Master.Lbtn1'"
This means, you cannot have a static property or method that references non static properties. Which is what you are doing.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thnks for your reply.
But it is not what i want to know.
The line which is not clear to me is
"
You can cast the Master property to be of your type of master page and access it's properties. I'd make such a property available via a base class so you can always access it.
"
Thats what i want to know in detail i.e How do we do that.
|
|
|
|
|
Create a new class, derived from the page class. Derive your pages from this class. In this class, add a property that returns your typed MasterPage, and tat converts the page master to be of this type. Then you can access it from the whole project.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
How to add a property in class file
that returns the typed MasterPage.
|
|
|
|
|
By writing actual code, in the manner I described. You just return the build in Master property, cast to your derived master page class.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
hi friends
i have three web user control
one is top banner
one is sidelinks
one is center part of the page
if drag drop ,the user control go to top only.
how can i position side and center in the page
regards
saravanan
Known Is Drop.Unknown Is Ocean
|
|
|
|