473,721 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Server.Execute reference created objects

Hi,

I have a basic aspx page, in the Page_Init procedure I have a
server.execute of another aspx page that adds some html code to my
first page. However it also adds a control (an htmlimage), now my
question is how to I get access to that control from the class in my
first page? Whenever I try to access it I get a "object reference not
set to an instance..." error.

Thank you,
Jonathan
Nov 18 '05 #1
3 1747
Tee
Well, I think you should knew the object name of that control, you can use
FindControl function.

the code should be something like this, I giving an example of FindControl
with TextBox
CType(FindContr ol("MyTextBox") , TextBox).Text = "Hello"

Change the "MyTextBox" to your object name, and "TextBox" to the object
type.
Tee

"Sophos" <so****@postmas ter.co.uk> wrote in message
news:95******** *************** ***@posting.goo gle.com...
Hi,

I have a basic aspx page, in the Page_Init procedure I have a
server.execute of another aspx page that adds some html code to my
first page. However it also adds a control (an htmlimage), now my
question is how to I get access to that control from the class in my
first page? Whenever I try to access it I get a "object reference not
set to an instance..." error.

Thank you,
Jonathan

Nov 18 '05 #2
Hi Sophos:

I'm not sure how Server.Execute can return an HtmlImage "control".
Server.Execute renders the page you ask it to execute, and you fetch
the same HTML a client would see if they requested the page with a
browser.

StringWriter writer = new StringWriter();
Server.Execute( "otherpage.aspx ",writer);
string html = writer.ToString ();
writer.Close();

You should have an image tag in the string, an image tag put in by an
HtmlImage control. You could use regular expressions or String.IndexOf
to search for the image tag, but you won't find a control.

HTH,

--
Scott
http://www.OdeToCode.com
On 9 Jul 2004 12:12:33 -0700, so****@postmast er.co.uk (Sophos) wrote:
Hi,

I have a basic aspx page, in the Page_Init procedure I have a
server.execu te of another aspx page that adds some html code to my
first page. However it also adds a control (an htmlimage), now my
question is how to I get access to that control from the class in my
first page? Whenever I try to access it I get a "object reference not
set to an instance..." error.

Thank you,
Jonathan


Nov 18 '05 #3
You can't directly do what it is you're trying to do but here's a work
around:

In your WebForm2, add code like this:
WebForm1 wf1 = (WebForm1)Conte xt.Handler;

That will make WebForm1 available to the page you called with
Server.Execute. Now, in WebForm1, create an image control with its visible
property set to false, or even an array to hold the information you want to
copy. Set the protection of the image control to public.

Create a property to return the image:

public System.Web.UI.W ebControls.Imag e MyImage
{
get { return Image1; }
set { Image1 = value; }
}
If you choose to use an array to get the values into, create a public
property in WebForm1 to return the array value:

private object imagePropertyVa lues[];

public object ImagePropertyVa lues[]
{
get { return imagePropertyVa lues; }
set { imagePropertyVa lues = value; }
}

In the code of your WebForm2, copy the properties you wish back to the
WebForm1 control or WebForm1 array. You can also copy the image object,
itself:

wf1.MyImage = Image1; // this line is in WebForm2.aspx.c s

That will let you retrieve property values back in WebForm1 but will not let
you dynamically control the values in WebForm2. If you want to dynamically
control the values in WebForm2, then create public properties or objects in
WebForm1 to hold those values prior to calling Server.Execute( "WebForm2") .
Then in the code for WebForm2, retrieve those values from the WebForm1
object you created in the first line of code above.

It's only slightly convoluted but you can, by using these concepts, set
values in WebForm2 and use those values in WebForm1 after WebForm2 completes
execution.

The one thing you cannot do is to change a value in WebForm2 controls after
WebForm2 returns. Think of WebForm2 as a method, and when it completes
execution, its fields are out of scope and cannot be accessed.

Dale
"Sophos" <so****@postmas ter.co.uk> wrote in message
news:95******** *************** ***@posting.goo gle.com...
Hi,

I have a basic aspx page, in the Page_Init procedure I have a
server.execute of another aspx page that adds some html code to my
first page. However it also adds a control (an htmlimage), now my
question is how to I get access to that control from the class in my
first page? Whenever I try to access it I get a "object reference not
set to an instance..." error.

Thank you,
Jonathan

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
9548
by: George Copeland | last post by:
This is a request for help fixing a SQL Server 2000/ADO problem on Windows XP. I would appreciate any useful assistance. PROBLEM: SQL Server access on my machine fails as follows: 1. All of my VB6 apps reference the following ADO typelib: Microsoft ActiveX Data Objects 2.7 Library Located at: c:\Program Files\Common Files\System\ADO\msado27.tlb
18
6145
by: Darryl Kerkeslager | last post by:
When I open an ADO Recordset, I close it. However, it seems that there may be some difference in this manner of opening a Recordset: Dim rL As ADODB.Recordset Set rL = New ADODB.Recordset src = "SELECT Count(*) FROM reviewer INNER JOIN pp_officer " & _ "ON reviewer.reviewer_id = pp_officer.ppo_rev_id " & _ "WHERE rev_login = 'EllisonL'" Set rL = CurrentProject.Connection.Execute(src, , adCmdText)
6
3735
by: Ken Allen | last post by:
I am relatively new to .Net and C#, but I hav ebeen programing in other languages and done some COM work for a number of years. I am attempting to understand how to map an older program architecture into .Net -- not looking to do it at this time, just to understand how I would achieve it. In the old environment, we had two classes, a client and a server class, that managed a data object. The server object knew how to interface with the...
6
1290
by: Skully | last post by:
If I have created my Web Application on my PC using command and connection objects (dragging them onto the forms from the Server Explorer window) how do I make it work when I deploy the application (and presumably the dB) to the Host server? The connection objects all refer to my PC not the server the app will eventually end up on? I guess my question is general. Where do I find out how to deploy a SQL Server/ASP.NET app to a...
11
6103
by: Bob | last post by:
I am in the process of upgrading an Access database to SQL Server (and climbing that learning curve!). The wizard happily upgraded all the tables and I can link to them OK using ODBC. The application controls allocation of revisions to aircraft maintenance manuals for an airline type operation. In the application there is a form loaded at start-up allowing the user/s to select the records that they are currently interested in from 4...
6
3858
by: polocar | last post by:
Hi, I'm writing a program in Visual C# 2005 Professional Edition. This program connects to a SQL Server 2005 database called "Generations" (in which there is only one table, called "Generations"), and it allows the user to add, edit and delete the various records of the table. "Generations" table has the following fields: "IDPerson", NamePerson", "AgePerson" and "IDParent". A record contains the information about a person (his name, his...
2
6962
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of attending interviews. If you own a company best way to judge if the candidate is worth of it. http://www.questpond.com/InterviewRatingSheet.zip
2
3980
by: astolpho | last post by:
I am using a slightly outdated reference book on J2EE programming. It gives 2 methods of creating a database used in its casestudies. The first is an ANT script that gives the following output: D:\original\CaseStudy-2-5\CaseStudy\Day02\exercise>asant database Buildfile: build.xml env-user: prop-user: set-user:
0
9367
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6669
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5981
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4484
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4753
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3189
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2130
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.