Hi to all I'm new in the forum and also new in the ASP.Net programing.
I have the following question/problem:
I have a Page(lets say Page1.aspx) this page has the following code

<iframe src="Page2.aspx" width="550" height="550"></iframe>

I was wandering If can declare methods/objects in the Page2.aspx and the Page1.aspx will know them.

My problem is that in Page2.aspx I do some work(lets say 2+2) and then I want to Page1.aspx to get the result from Page2.aspx (ofcourse the 2+2 is a simplify example).
If this is possible how is this done, maybe you have a link where I can see an example.
Thanks

No, this is not possible the way you are wanting. If you wish to do this, you would have to do a cross-page postback, then redirect back to the current page. So by doing this, you will make these functions somewhat unique to each page. Therefore you might as well make them into a class (a file with common code) and call it from there, or duplicate each function on each page. Repeated code is only hard for the programmer, as the viewer does not download extra code, use extra bandwidth, etc. It's just more difficult to maintain. My recommendations would be just to have the function on each page, unless you will be using it more than 2 or 3 times. If so, put it into a class, and place a reference to the class in your site. Call the class by calling: ClassName obj = new ClassName(); Then call your method within that class: obj.methodCall();

This article has been dead for over six months. Start a new discussion instead.