Showing posts with label created. Show all posts
Showing posts with label created. Show all posts

Monday, March 26, 2012

Server tag not well formed error.

I have created a custom image control everything works fine. It renders in the browser fine.

But when I drop the control in the webform, set the properties, go to html view, then back to design view. I get a gray box where my custom control was that says "Error Creating Custom Control" and then a message of "Server Tag is not well formed".

Anyone know why this would happen?
Here is how it looks in HMTL view from within the IDE.

<JHA:JHAImageRollover id="JHAImageRollover1" onclick="http://www.google.com" runat="server" BaseImage="/common/images/btn_search.gif" RolloverImage="/common/images/btn_cancel.gif"></JHA:JHAImageRollover>Is there are <@.Register > tag on the top of the .aspx page that the control is on?

My guess is the page doesn't know anything about the control since its library is not registered with the page.

<%@. Register TagPrefix="jh1" Namespace="YourControlLibraryNamespace" Assembly="YourControlLibrary" %>
Got it fixed...strange though.

The TagPrefix in the page directive was "jha"
it was yelling because the control had "JHA"

go figure!?

Saturday, March 24, 2012

Server.CreateObject: Making objects visible

I would like to make an DCOM-object created by an ASP page visible for debugging purposes.
For instance: I have the following code:

SET objExcel = Server.CreateObject("Excel.Application.10")
objExcel.Application.Visible = True
SET Session.Contents("myexcel") = objExcel

When I run this code, the Excel object is created and stored in a session variable for later use. However, on my machine it is not visible, although I have set the visible property to True.
I can see that the EXCEL object was created by opening in the process page of the WINDOWS Task-Manager
I tried also to Server.CreateObject several other objects with the same result: Although I have set the visible property to true they just do not show up.
What me make wondering about this is that a couple a weeks ago everything worked fine, the Server.Created objects were visible, but I must have changed something on my machine because now they remain invisible.
Does anybody has a clue on this?Just found the solution:
in the DCOM-Configuration the identity must be Interactive User (NOT user who started the application)
Already thought this was a Windows Privileges problem
I've been having the same problem - getting Excel to become visible. How do you configure the identity to be Interactive User? Is it in the dcomcnfg utility?

When I run my app, I can see EXCEL.EXE in my task manager, but it is not visible and I, too, use the visible=true setting.

It's been plaguing me for about a week now.
I'm a bit new, so go easy....

Rykri11
Yes with Windows 2000 you'll have to run dcomcnfg.exe while with WindowsXP you'll also find it at computer administration (component services)
Then you need to find your application (MS Excel) and edit the properties of this application (right-mouse click with XP, push-button with Windows 2000). On the 4th page named "identity" of the page selector you'll need to set the user to "interactive user"

Server.execute

Hi,
I face a problem
is it possible to access an asp/vbscript variable created in the parent by t
he child in the server.execute.
If so an example block.
TIA.
Raj.going to have to either pass it (form, querystring) or store it and read it
back in (application var, db, cookie, session, etc).
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Raj" <Raj@.discussions.microsoft.com> wrote in message
news:19B6E194-6F51-4EBC-8AD2-CA3330F22E89@.microsoft.com...
> Hi,
> I face a problem
> is it possible to access an asp/vbscript variable created in the parent by
the child in the server.execute.
> If so an example block.
> TIA.
> Raj.

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

Tuesday, March 13, 2012

server.mappath challenging problem

I created a page that uses the following line in it.:

Public votingDatabasePath = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.mappath("/datasources/votingDB.mdb")

and the page worked brilliantly.
I then changed this into a web user control, and the program always crashes on this line saying the following. The weird thing is that I load the user control in a try catch statement, so the page should never go to the full error page.

Any help would be greatly appriciated.

Jagdip

---------------------------
System.NullReferenceException: Object reference not set to an instance of an object.

The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:

1. Add a "Debug=true" directive at the top of the file that generated the error. Example:

<%@dotnet.itags.org. Page Language="C#" Debug="true" %
or:

2) Add the following section to the configuration file of your application:

<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration
Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.

Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.
---------------------------
Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
System.Web.UI.UserControl.get_Server() +8
_test.jags_voting..ctor() in C:\Documents and Settings\.....voting\jags_voting.ascx.vb:18
ASP.jags_voting_ascx..ctor()

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeType.CreateInstanceImpl(Boolean publicOnly) +0
System.Activator.CreateInstance(Type type, Boolean nonPublic) +66
System.Web.UI.PartialCachingControl.CreateCachedControl() +225
System.Web.UI.BasePartialCachingControl.OnInit(EventArgs e) +93
System.Web.UI.Control.InitRecursive(Control namingContainer) +241
System.Web.UI.Control.InitRecursive(Control namingContainer) +179
System.Web.UI.Control.InitRecursive(Control namingContainer) +179
System.Web.UI.Control.InitRecursive(Control namingContainer) +179
System.Web.UI.Control.InitRecursive(Control namingContainer) +179
System.Web.UI.Control.InitRecursive(Control namingContainer) +179
System.Web.UI.Control.InitRecursive(Control namingContainer) +179
System.Web.UI.Control.AddedControl(Control control, Int32 index) +185
System.Web.UI.ControlCollection.Add(Control child) +153
_test.JagsDTGDashboard.writePanels() in C:\Documents and Settings\.....\JagsDTGDashboard.aspx.vb:666
_test.JagsDTGDashboard.dropDownListIndexChanged(Object sender, EventArgs e) in C:\Documents and Settings\....\JagsDTGDashboard.aspx.vb:259
System.Web.UI.WebControls.ListControl.OnSelectedIndexChanged(EventArgs e) +108
System.Web.UI.WebControls.DropDownList.System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent() +26
System.Web.UI.Page.RaiseChangedEvents() +115
System.Web.UI.Page.ProcessRequestMain() +1072Server is not a property ofWebControl orControl, which are inherited by theUser Control. You have to reference Server via the Page property:

Public votingDatabasePath = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &Page.Server.mappath("/datasources/votingDB.mdb")

I'm afraid that that has not solved the problem. The same error appears.

I'm just wondering what the ..ctor() means in

[NullReferenceException: Object reference not set to an instance of an object.]
System.Web.UI.UserControl.get_Server() +8
_test.jags_voting..ctor() in C:\Documents and Settings\.....voting\jags_voting.ascx.vb:18
ASP.jags_voting_ascx..ctor()

Jagdip
I'm pretty sure that ..ctor() means 'constructor'. the control is failing to get created. With web controls, I have found that I have to make sure that any relative paths are relative to the parent page that will run the control. If your page that hosts the control is in a different folder from the control, the results are a little unpredictable.