Showing posts with label basic. Show all posts
Showing posts with label basic. Show all posts

Saturday, March 31, 2012

Server Side Debugging error in Hello World Application

Hi,

I'm new to the ASP.NET /.NET programming so excuse my very basic question. I
was trying to write the Hello World Application using ASP.Net using C# in
Visual Studio.Net
When I debug the application I get the error....

"Error while trying to run project. Unable to start debugging on the web
server. Server side-error occurred on sending debug HTTP request"

I have checked the usual Web.config for all the flags and also made my
Windows Domain User ID member of Debugger group etc.

Could someone please help and tell where I should look into to solve this
problem. This is very frustrating for me

regards
Bikram SuriThis might be of help... http://support.microsoft.com/?id=303067

"Bikram Suri" <bsuri@.hotmail.com> wrote in message
news:e0W91w4sFHA.2348@.tk2msftngp13.phx.gbl...
> Hi,
> I'm new to the ASP.NET /.NET programming so excuse my very basic question.
> I
> was trying to write the Hello World Application using ASP.Net using C# in
> Visual Studio.Net
> When I debug the application I get the error....
> "Error while trying to run project. Unable to start debugging on the web
> server. Server side-error occurred on sending debug HTTP request"
> I have checked the usual Web.config for all the flags and also made my
> Windows Domain User ID member of Debugger group etc.
> Could someone please help and tell where I should look into to solve this
> problem. This is very frustrating for me
> regards
> Bikram Suri

Server Side Debugging error in Hello World Application

Hi,
I'm new to the ASP.NET /.NET programming so excuse my very basic question. I
was trying to write the Hello World Application using ASP.Net using C# in
Visual Studio.Net
When I debug the application I get the error....
"Error while trying to run project. Unable to start debugging on the web
server. Server side-error occurred on sending debug HTTP request"
I have checked the usual Web.config for all the flags and also made my
Windows Domain User ID member of Debugger group etc.
Could someone please help and tell where I should look into to solve this
problem. This is very frustrating for me
regards
Bikram SuriThis might be of help... http://support.microsoft.com/?id=303067
"Bikram Suri" <bsuri@.hotmail.com> wrote in message
news:e0W91w4sFHA.2348@.tk2msftngp13.phx.gbl...
> Hi,
> I'm new to the ASP.NET /.NET programming so excuse my very basic question.
> I
> was trying to write the Hello World Application using ASP.Net using C# in
> Visual Studio.Net
> When I debug the application I get the error....
> "Error while trying to run project. Unable to start debugging on the web
> server. Server side-error occurred on sending debug HTTP request"
> I have checked the usual Web.config for all the flags and also made my
> Windows Domain User ID member of Debugger group etc.
> Could someone please help and tell where I should look into to solve this
> problem. This is very frustrating for me
> regards
> Bikram Suri
>
>

server side include or user control?

I am setting up an asp.net site using the Ektron CMS. Every page in the
site uses the same basic template, with the look of the page changing
via CSS and an id on the body. The id is shared by all pages in a
subsection, e.g. everything in /about/ needs to have <body id="about">.
In the past what I've done is set a global variable in index.asp, then
include the template to render the page:
<%
pageid = "about"
defaultcontentid = 33
%>
<!--#include virtual="/include/mastertemplate.asp" -->
mastertemplate.asp would be the entire page, echoing and processing the
variables like so:
<!--#include virtual="/include/cmsfunctions.asp" -->
<body id="<%= pageid %>">
<%= cmsRenderContent(defaultcontentid) %>
This worked great. I needed one index.asp for each subsection, and had
no duplication of template code. If the template needed to be updated, I
just gave it to the designer, who modified it in Dreamweaver or
whatever. The separation between presentation and logic was good, and
any code that generated html was in an easily-modified function.
I've experimented with a similar approach in asp.net, and have the start
of it working, but the additional complication is that
mastertemplate.aspx has some codebehind related to the cms server
controls that it uses, and I need to use the passed-in variables within
that codebehind. For example, I'd establish a default content id in the
calling page, and if the mastertemplate.asp doesn't detect an id in the
url, it will use the default.
I am looking for examples of this approach in asp.net but I keep running
across advice to use user controls instead. But it seems like user
controls are used for parts of pages, not the page template itself. Is
that right? Can a user control contain server controls? How would I pass
variables from a "stub" calling page to the user control page? Can a
user control be modified in something like Dreamweaver?
Thanks,
markgenerally they are right.
You will typically put a "place holder" into the template and then replace
that "place holder" with content created from a control (.ascx file). the
content is injected into the position of the "place holder" by using the
page.loadcontrol method.
example:
--
...somewhere in your code
' Dynamically inject a signin login module into the page
'---
If Request.IsAuthenticated = False Then
LoginControl.Controls.Add(Page.LoadControl("~/SignIn.ascx"))
End If
... somewhere in your template
<asp:placeholder id="LoginControl" runat="server" />
"Mark" <mark12b@.yahoo.com> wrote in message
news:mark12b-F29D08.12133710052005@.news.isp.giganews.com...
>I am setting up an asp.net site using the Ektron CMS. Every page in the
> site uses the same basic template, with the look of the page changing
> via CSS and an id on the body. The id is shared by all pages in a
> subsection, e.g. everything in /about/ needs to have <body id="about">.
> In the past what I've done is set a global variable in index.asp, then
> include the template to render the page:
> <%
> pageid = "about"
> defaultcontentid = 33
> %>
> <!--#include virtual="/include/mastertemplate.asp" -->
> mastertemplate.asp would be the entire page, echoing and processing the
> variables like so:
> <!--#include virtual="/include/cmsfunctions.asp" -->
> <body id="<%= pageid %>">
> <%= cmsRenderContent(defaultcontentid) %>
> This worked great. I needed one index.asp for each subsection, and had
> no duplication of template code. If the template needed to be updated, I
> just gave it to the designer, who modified it in Dreamweaver or
> whatever. The separation between presentation and logic was good, and
> any code that generated html was in an easily-modified function.
> I've experimented with a similar approach in asp.net, and have the start
> of it working, but the additional complication is that
> mastertemplate.aspx has some codebehind related to the cms server
> controls that it uses, and I need to use the passed-in variables within
> that codebehind. For example, I'd establish a default content id in the
> calling page, and if the mastertemplate.asp doesn't detect an id in the
> url, it will use the default.
> I am looking for examples of this approach in asp.net but I keep running
> across advice to use user controls instead. But it seems like user
> controls are used for parts of pages, not the page template itself. Is
> that right? Can a user control contain server controls? How would I pass
> variables from a "stub" calling page to the user control page? Can a
> user control be modified in something like Dreamweaver?
> Thanks,
> --
> mark
Include files are old fashioned.
User controls are a better approach. Yes, they can contain any kind of
controls you'd like. You can create public properties, methods, and events
to facilitate communication between the user control and the page.
I agree with you that user controls do not fully achieve the "template"
functionality you s as gracefully as we'd all like, but the only great
solution is in ASP.NET 2.0 (due out later this year) which implements
"Master Pages".
Here's more info:
http://SteveOrr.net/faq/usercustom.aspx
http://www.c-sharpcorner.com/Code/2...MasterPages.asp
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Mark" <mark12b@.yahoo.com> wrote in message
news:mark12b-F29D08.12133710052005@.news.isp.giganews.com...
>I am setting up an asp.net site using the Ektron CMS. Every page in the
> site uses the same basic template, with the look of the page changing
> via CSS and an id on the body. The id is shared by all pages in a
> subsection, e.g. everything in /about/ needs to have <body id="about">.
> In the past what I've done is set a global variable in index.asp, then
> include the template to render the page:
> <%
> pageid = "about"
> defaultcontentid = 33
> %>
> <!--#include virtual="/include/mastertemplate.asp" -->
> mastertemplate.asp would be the entire page, echoing and processing the
> variables like so:
> <!--#include virtual="/include/cmsfunctions.asp" -->
> <body id="<%= pageid %>">
> <%= cmsRenderContent(defaultcontentid) %>
> This worked great. I needed one index.asp for each subsection, and had
> no duplication of template code. If the template needed to be updated, I
> just gave it to the designer, who modified it in Dreamweaver or
> whatever. The separation between presentation and logic was good, and
> any code that generated html was in an easily-modified function.
> I've experimented with a similar approach in asp.net, and have the start
> of it working, but the additional complication is that
> mastertemplate.aspx has some codebehind related to the cms server
> controls that it uses, and I need to use the passed-in variables within
> that codebehind. For example, I'd establish a default content id in the
> calling page, and if the mastertemplate.asp doesn't detect an id in the
> url, it will use the default.
> I am looking for examples of this approach in asp.net but I keep running
> across advice to use user controls instead. But it seems like user
> controls are used for parts of pages, not the page template itself. Is
> that right? Can a user control contain server controls? How would I pass
> variables from a "stub" calling page to the user control page? Can a
> user control be modified in something like Dreamweaver?
> Thanks,
> --
> mark
In article <#3rMAzZVFHA.3696@.TK2MSFTNGP10.phx.gbl>,
"Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote:

> I agree with you that user controls do not fully achieve the "template"
> functionality you s as gracefully as we'd all like, but the only great
> solution is in ASP.NET 2.0 (due out later this year) which implements
> "Master Pages".
> Here's more info:
> http://SteveOrr.net/faq/usercustom.aspx
> http://www.c-sharpcorner.com/Code/2...MasterPages.asp
Yes, Master Pages is most like what I was after. Now I am thinking about
just passing the section name in the url and have everything run through
a single page. Instead of
/about/index.aspx?id=123
/portfolio/index.aspx?id=456
I'll go
/index.aspx?s=about&id=123
/index.aspx?s=portfolio&id=456
This should work fine, especially since the cms has url aliasing.
Thnkas,
Yes, I've tried that approach before and it's not as easy as it might seem
at first.
Since everything is essentially a postback to the same page, this opens up
new hassles related to dynamically creating controls at runtime and managing
them all between postbacks and keeping them from conflicting with eachother
in various ways.
If you can, skip to ASP.NET 2.0 and use master pages. Otherwise I'd suggest
you use multiple pages with header and/or footer controls to help manage a
common look & feel.
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Mark" <mark12b@.yahoo.com> wrote in message
news:mark12b-377F1D.14180810052005@.news.isp.giganews.com...
> In article <#3rMAzZVFHA.3696@.TK2MSFTNGP10.phx.gbl>,
> "Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote:
>
> Yes, Master Pages is most like what I was after. Now I am thinking about
> just passing the section name in the url and have everything run through
> a single page. Instead of
> /about/index.aspx?id=123
> /portfolio/index.aspx?id=456
> I'll go
> /index.aspx?s=about&id=123
> /index.aspx?s=portfolio&id=456
> This should work fine, especially since the cms has url aliasing.
> Thnkas,

server side include or user control?

I am setting up an asp.net site using the Ektron CMS. Every page in the
site uses the same basic template, with the look of the page changing
via CSS and an id on the body. The id is shared by all pages in a
subsection, e.g. everything in /about/ needs to have <body id="about">.

In the past what I've done is set a global variable in index.asp, then
include the template to render the page:

<%
pageid = "about"
defaultcontentid = 33
%>
<!--#include virtual="/include/mastertemplate.asp" --
mastertemplate.asp would be the entire page, echoing and processing the
variables like so:

<!--#include virtual="/include/cmsfunctions.asp" -->
<body id="<%= pageid %>">
<%= cmsRenderContent(defaultcontentid) %
This worked great. I needed one index.asp for each subsection, and had
no duplication of template code. If the template needed to be updated, I
just gave it to the designer, who modified it in Dreamweaver or
whatever. The separation between presentation and logic was good, and
any code that generated html was in an easily-modified function.

I've experimented with a similar approach in asp.net, and have the start
of it working, but the additional complication is that
mastertemplate.aspx has some codebehind related to the cms server
controls that it uses, and I need to use the passed-in variables within
that codebehind. For example, I'd establish a default content id in the
calling page, and if the mastertemplate.asp doesn't detect an id in the
url, it will use the default.

I am looking for examples of this approach in asp.net but I keep running
across advice to use user controls instead. But it seems like user
controls are used for parts of pages, not the page template itself. Is
that right? Can a user control contain server controls? How would I pass
variables from a "stub" calling page to the user control page? Can a
user control be modified in something like Dreamweaver?

Thanks,

--
markgenerally they are right.

You will typically put a "place holder" into the template and then replace
that "place holder" with content created from a control (.ascx file). the
content is injected into the position of the "place holder" by using the
page.loadcontrol method.

example:
--------
...somewhere in your code

' Dynamically inject a signin login module into the page
'---------------------
If Request.IsAuthenticated = False Then
LoginControl.Controls.Add(Page.LoadControl("~/SignIn.ascx"))
End If

.... somewhere in your template

<asp:placeholder id="LoginControl" runat="server" /
"Mark" <mark12b@.yahoo.com> wrote in message
news:mark12b-F29D08.12133710052005@.news.isp.giganews.com...
>I am setting up an asp.net site using the Ektron CMS. Every page in the
> site uses the same basic template, with the look of the page changing
> via CSS and an id on the body. The id is shared by all pages in a
> subsection, e.g. everything in /about/ needs to have <body id="about">.
> In the past what I've done is set a global variable in index.asp, then
> include the template to render the page:
> <%
> pageid = "about"
> defaultcontentid = 33
> %>
> <!--#include virtual="/include/mastertemplate.asp" -->
> mastertemplate.asp would be the entire page, echoing and processing the
> variables like so:
> <!--#include virtual="/include/cmsfunctions.asp" -->
> <body id="<%= pageid %>">
> <%= cmsRenderContent(defaultcontentid) %>
> This worked great. I needed one index.asp for each subsection, and had
> no duplication of template code. If the template needed to be updated, I
> just gave it to the designer, who modified it in Dreamweaver or
> whatever. The separation between presentation and logic was good, and
> any code that generated html was in an easily-modified function.
> I've experimented with a similar approach in asp.net, and have the start
> of it working, but the additional complication is that
> mastertemplate.aspx has some codebehind related to the cms server
> controls that it uses, and I need to use the passed-in variables within
> that codebehind. For example, I'd establish a default content id in the
> calling page, and if the mastertemplate.asp doesn't detect an id in the
> url, it will use the default.
> I am looking for examples of this approach in asp.net but I keep running
> across advice to use user controls instead. But it seems like user
> controls are used for parts of pages, not the page template itself. Is
> that right? Can a user control contain server controls? How would I pass
> variables from a "stub" calling page to the user control page? Can a
> user control be modified in something like Dreamweaver?
> Thanks,
> --
> mark
Include files are old fashioned.
User controls are a better approach. Yes, they can contain any kind of
controls you'd like. You can create public properties, methods, and events
to facilitate communication between the user control and the page.
I agree with you that user controls do not fully achieve the "template"
functionality you seek as gracefully as we'd all like, but the only great
solution is in ASP.NET 2.0 (due out later this year) which implements
"Master Pages".

Here's more info:
http://SteveOrr.net/faq/usercustom.aspx
http://www.c-sharpcorner.com/Code/2...MasterPages.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

"Mark" <mark12b@.yahoo.com> wrote in message
news:mark12b-F29D08.12133710052005@.news.isp.giganews.com...
>I am setting up an asp.net site using the Ektron CMS. Every page in the
> site uses the same basic template, with the look of the page changing
> via CSS and an id on the body. The id is shared by all pages in a
> subsection, e.g. everything in /about/ needs to have <body id="about">.
> In the past what I've done is set a global variable in index.asp, then
> include the template to render the page:
> <%
> pageid = "about"
> defaultcontentid = 33
> %>
> <!--#include virtual="/include/mastertemplate.asp" -->
> mastertemplate.asp would be the entire page, echoing and processing the
> variables like so:
> <!--#include virtual="/include/cmsfunctions.asp" -->
> <body id="<%= pageid %>">
> <%= cmsRenderContent(defaultcontentid) %>
> This worked great. I needed one index.asp for each subsection, and had
> no duplication of template code. If the template needed to be updated, I
> just gave it to the designer, who modified it in Dreamweaver or
> whatever. The separation between presentation and logic was good, and
> any code that generated html was in an easily-modified function.
> I've experimented with a similar approach in asp.net, and have the start
> of it working, but the additional complication is that
> mastertemplate.aspx has some codebehind related to the cms server
> controls that it uses, and I need to use the passed-in variables within
> that codebehind. For example, I'd establish a default content id in the
> calling page, and if the mastertemplate.asp doesn't detect an id in the
> url, it will use the default.
> I am looking for examples of this approach in asp.net but I keep running
> across advice to use user controls instead. But it seems like user
> controls are used for parts of pages, not the page template itself. Is
> that right? Can a user control contain server controls? How would I pass
> variables from a "stub" calling page to the user control page? Can a
> user control be modified in something like Dreamweaver?
> Thanks,
> --
> mark
In article <#3rMAzZVFHA.3696@.TK2MSFTNGP10.phx.gbl>,
"Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote:

> I agree with you that user controls do not fully achieve the "template"
> functionality you seek as gracefully as we'd all like, but the only great
> solution is in ASP.NET 2.0 (due out later this year) which implements
> "Master Pages".
> Here's more info:
> http://SteveOrr.net/faq/usercustom.aspx
> http://www.c-sharpcorner.com/Code/2...MasterPages.asp

Yes, Master Pages is most like what I was after. Now I am thinking about
just passing the section name in the url and have everything run through
a single page. Instead of

/about/index.aspx?id=123
/portfolio/index.aspx?id=456

I'll go

/index.aspx?s=about&id=123
/index.aspx?s=portfolio&id=456

This should work fine, especially since the cms has url aliasing.

Thnkas,
Yes, I've tried that approach before and it's not as easy as it might seem
at first.
Since everything is essentially a postback to the same page, this opens up
new hassles related to dynamically creating controls at runtime and managing
them all between postbacks and keeping them from conflicting with eachother
in various ways.
If you can, skip to ASP.NET 2.0 and use master pages. Otherwise I'd suggest
you use multiple pages with header and/or footer controls to help manage a
common look & feel.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

"Mark" <mark12b@.yahoo.com> wrote in message
news:mark12b-377F1D.14180810052005@.news.isp.giganews.com...
> In article <#3rMAzZVFHA.3696@.TK2MSFTNGP10.phx.gbl>,
> "Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote:
>> I agree with you that user controls do not fully achieve the "template"
>> functionality you seek as gracefully as we'd all like, but the only great
>> solution is in ASP.NET 2.0 (due out later this year) which implements
>> "Master Pages".
>>
>> Here's more info:
>> http://SteveOrr.net/faq/usercustom.aspx
>> http://www.c-sharpcorner.com/Code/2...MasterPages.asp
> Yes, Master Pages is most like what I was after. Now I am thinking about
> just passing the section name in the url and have everything run through
> a single page. Instead of
> /about/index.aspx?id=123
> /portfolio/index.aspx?id=456
> I'll go
> /index.aspx?s=about&id=123
> /index.aspx?s=portfolio&id=456
> This should work fine, especially since the cms has url aliasing.
> Thnkas,

Thursday, March 29, 2012

Server side Timer component in ASP.net

Hello All,
In desktop application whenever we wanted to have some code repeated
running we used to have timer component in Visual Basic. I want to have
same logic on serverside now. Like creating some reports every day,
sending mail at certain time etc, which user access everyday.
Currently, I am using NT Scheduler having my WinApps running. but I
have to manually add tasks there. Is there anyway, to put this in IIS
infrastructure itself? How can one schedule code to run in future at
certain date and time on server?
Best Regards,
NeoA Windows Service would be a more appropriate application type that an
ASP.NET application for the needs you've described.
Here's more info on Windows Services:
http://msdn.microsoft.com/library/d...pplications.asp
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Neo" <pravinsable@.gmail.com> wrote in message
news:1147295406.648404.18920@.j73g2000cwa.googlegroups.com...
> Hello All,
> In desktop application whenever we wanted to have some code repeated
> running we used to have timer component in Visual Basic. I want to have
> same logic on serverside now. Like creating some reports every day,
> sending mail at certain time etc, which user access everyday.
> Currently, I am using NT Scheduler having my WinApps running. but I
> have to manually add tasks there. Is there anyway, to put this in IIS
> infrastructure itself? How can one schedule code to run in future at
> certain date and time on server?
> Best Regards,
> Neo
>

Server side Timer component in ASP.net

Hello All,

In desktop application whenever we wanted to have some code repeated
running we used to have timer component in Visual Basic. I want to have
same logic on serverside now. Like creating some reports every day,
sending mail at certain time etc, which user access everyday.
Currently, I am using NT Scheduler having my WinApps running. but I
have to manually add tasks there. Is there anyway, to put this in IIS
infrastructure itself? How can one schedule code to run in future at
certain date and time on server?

Best Regards,
NeoA Windows Service would be a more appropriate application type that an
ASP.NET application for the needs you've described.

Here's more info on Windows Services:
http://msdn.microsoft.com/library/d...pplications.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

"Neo" <pravinsable@.gmail.com> wrote in message
news:1147295406.648404.18920@.j73g2000cwa.googlegro ups.com...
> Hello All,
> In desktop application whenever we wanted to have some code repeated
> running we used to have timer component in Visual Basic. I want to have
> same logic on serverside now. Like creating some reports every day,
> sending mail at certain time etc, which user access everyday.
> Currently, I am using NT Scheduler having my WinApps running. but I
> have to manually add tasks there. Is there anyway, to put this in IIS
> infrastructure itself? How can one schedule code to run in future at
> certain date and time on server?
> Best Regards,
> Neo

Thursday, March 22, 2012

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,
JonathanWell, 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(FindControl("MyTextBox"), TextBox).Text = "Hello"

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

Tee

"Sophos" <sophos@.postmaster.co.uk> wrote in message
news:9590ee74.0407091112.4f6ba07b@.posting.google.c om...
> 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
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, sophos@.postmaster.co.uk (Sophos) wrote:

>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
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)Context.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.WebControls.Image 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 imagePropertyValues[];

public object ImagePropertyValues[]
{
get { return imagePropertyValues; }
set { imagePropertyValues = 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.cs

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" <sophos@.postmaster.co.uk> wrote in message
news:9590ee74.0407091112.4f6ba07b@.posting.google.c om...
> 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

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,
JonathanWell, 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(FindControl("MyTextBox"), TextBox).Text = "Hello"
Change the "MyTextBox" to your object name, and "TextBox" to the object
type.
Tee
"Sophos" <sophos@.postmaster.co.uk> wrote in message
news:9590ee74.0407091112.4f6ba07b@.posting.google.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
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, sophos@.postmaster.co.uk (Sophos) wrote:

>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
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)Context.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.WebControls.Image 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 imagePropertyValues[];
public object ImagePropertyValues[]
{
get { return imagePropertyValues; }
set { imagePropertyValues = 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.cs
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" <sophos@.postmaster.co.uk> wrote in message
news:9590ee74.0407091112.4f6ba07b@.posting.google.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