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.
0 comments:
Post a Comment