Solved

Need Helep with Error Rendering Control on ascx User control pages

Posted on 2013-01-19
12
1,240 Views
Last Modified: 2013-02-01
Hi,

I am trying to learn how to write code to develop web pages using ASP.Net.  On a web user control called movement.ascx, I am getting a "Error Rendering Control" An unhandled exception Object reference not set to an instance of an object"

Now I need help and I am paying for help with this site $12.95 monthly.  When I ask questions I want help.  Please do not respond to my questions with an address link to researched pages.  I can do this on my own without your help.  

If you know how to help me, please do specifically and explain what to do to solve the problem.  Remember, I am not an expert.  I am an amateur trying to piece together.
So do not assume I know what you mean.

Anyhow:  My code again movement.ascx.

In design view, I get the error rendering control.  The application works completely.
I just want to get rid of the error rendering control message in the design view.

The Code:

<%@ Control Language="VB" AutoEventWireup="false" CodeFile="Movement.ascx.vb" Inherits="Controls_Movement" %>

< %@ Register Assembly="DOC" Namespace="DOC.Controls" TagPrefix="DOC" %>
< %@ Register Src="~/Controls/Movement/inmateGroup.ascx" TagName="inmateGroup" TagPrefix="IMAS" %>
< %@ Register Src="~/Controls/Movement/HoldingBin.ascx" TagName="HoldingBin" TagPrefix="IMAS" %>
< %@ Register Src="~/Controls/VerifyPassword.ascx" TagName="VerifyPassword" TagPrefix="IMAS" %>
< %@ Register Src="~/Controls/Movement/Confirmation.ascx" TagName="Confirmation" TagPrefix="Movement" %>

< script type="text/javascript">
function inmateSearch() {document.location.href = '<%=InmateSearchHref%>';}
< /script>





< div id="saveButton" runat="server" style="display:inline;">
<input type="button" id="cmdSave" runat="server" value="Save" disabled="disabled" style="width:100px;margin:10px 0px 0px 6px;"/>
< /div>

< DOC rogressindicator id="ProgressIndicator1" runat="server"/>
< IMAS:VerifyPassword ID="VerifyPassword1" runat="server" RefreshOnPageLoad="true"/>
< DOC:InmateValidator id="InmateValidator1" runat="Server" RefreshOnPageLoad="false"/>

< DOC:ProgressIndicator id="ProgressIndicator" runat="server"/>




< div id="rootElement" runat="server" style="position:absolute;z-index:101;left:5px;top:5px;width:99%;height:600px;">

<Movement:Confirmation ID="MovementConfirmation1" runat="server" RefreshOnPageLoad="false"/>

<table cellpadding="0" cellspacing="8" border="0"
style="position:relative;top:-10px;left:-5px; height: 865px;">
<tr>
<td style="width:416px;"><IMAS:InmateGroup ID="InmateGroup1" runat="server"/></td>
<td style="width:416px;"><IMAS:InmateGroup ID="InmateGroup2" runat="server"/></td>
</tr>
<tr>
<td colspan="2">
<IMAS:HoldingBin ID="HoldingBin1" runat="server"/>
</td>
</tr>
</table>

<input type="text" id="txtDuration" value="0" style="display:none" />

<!-- Hide template elements -->
<div class="templates" style="display:none">
<!-- DropCue Template -->
<div id="dropCueTemplate" class="dropCue">Drop?</div>
<!-- Empty Template -->
<div id="emptyTemplate" class="emptyList"></div>
<div id="emptyInmateTemplate"></div>
</div>
<div id="divInmateSearch" runat="server" style="position:absolute;top:0px;left:850px;z-index:1200;">
<img src="~../Images/InmateSearch.gif"
onmouseover="changeButtonImage('../Images/InmateSearch_mouseover.gif');"
onmouseout="changeButtonImage('../Images/InmateSearch.gif');"
onmousedown= "changeButtonImage('../Images/InmateSearch_mousedown.gif');" alt="Search for an Inmate"
onclick="inmateSearch();"
/>
</div>
< /div>

Please help.

jjc9809
0
Comment
Question by:jjc9809
  • 7
  • 3
  • 2
12 Comments
 
LVL 6

Expert Comment

by:esolve
ID: 38797844
The object reference error you get is because you are accessing a member variable from the code behind page. Also you are accessing this variable using asp3.0 code.

I have also found this very frustrating. Visual Studio does eventually resolve this but sometimes seems to take ages to pick up that the variable does actually exists in the code behind page.

Please ensure you have this variable "InmateSearchHref" properly declared in your code behind page like this.

public InmateSearchHref as String

Also ensure that this variable gets set eg. in the page load event.

InmateSearchHref = "http://whateeryoururl.aspx"

Another aproach would be to set the attributes in the code behind.

Dim redirectURL as String
img.Attributes.Add("onclick", "inmateSearch(" + redirectURL + ");");

Then you wont get this error. Just ensure that your img has an id attribute and the runat=server is set.

O and obviously you need to change your javascript method to accept the redirect parameter.

function inmateSearch(url) {
 document.location.href = url;
}
0
 
LVL 20

Expert Comment

by:informaniac
ID: 38799008
For me, such issues get resolved, once I click on html in Design View and press F7.
0
 

Author Comment

by:jjc9809
ID: 38801421
esolve,

I am going to try your solutions when I return to work Tuesday after the holiday. I believe your solution wll help me after reading it.  But, all of my ascx pages in design view have these same error rendering controls, but the entire application is working.  There is a problem dropping inmates into the holding bin which is another problem in its self.

jjc9809
0
 

Author Comment

by:jjc9809
ID: 38801427
Infomaniac,
 
What are you accomplishing by selecting design view and selecting F7?  What does this mean?

jjc9809
0
 
LVL 20

Expert Comment

by:informaniac
ID: 38801453
Basically when in design mode the variables do not get updated, if I do a Right Click and click on View Code, the variables get updated properly. i.e. if I change the textbox name/id and it is not reflected.

Anyway, this is just a suggestion.
0
 

Author Comment

by:jjc9809
ID: 38805853
Esolve,

This is what I have shown on my code behind page, Movement.ascx.vb.

Imports System.Web.UI


Partial Class Controls_Movement


    Inherits DOC.IMAS.MovementControl_BinAndHousingUnitList

    Public AIS As String
    Public InmateSearchHref As String
    Public InmateGroups As New ArrayList

    Public Overrides Sub Refresh()
        Control = rootElement
        ScriptClassName = "DOC.IMAS.Movement.Movement"
        ScriptFilePath = "~/script/DOC.IMAS.Movement.Movement.js"

        AIS = Request.QueryString("AIS")
        InstID = Master.InstID

        _InitializeControls()

        GetBinsAndHousingUnits()

        AddClientProperty("bins", SerializeBins)
        AddClientProperty("housingUnits", SerializeHousingUnits)
        AddClientProperty("instID", InstID)
        AddClientProperty("locationID", Master.LocationID)
        AddClientProperty("AIS", AIS)

        AddDomElement("cmdSave", cmdSave.ClientID)
        AddDomElement("divMasterTitleBar", Master.TitleBar.ClientID)

        AddObjectReference("inmateValidator", InmateValidator1.Control.ClientID)
        AddObjectReference("movementConfirmation", MovementConfirmation1.Control.ClientID)
        AddObjectReference("verifyPassword", VerifyPassword1.Control.ClientID)

        AddObjectReferenceArray("inmateGroups", InmateGroups)

        InmateSearchHref = ConfigurationManager.AppSettings("DocFind") & "Default.aspx?Target=" + Server.UrlEncode(Request.Path.Replace("MovementPopup", "Movement")) & "&InstID=" & InstID
    End Sub

    Private Sub _InitializeControls()
        'TODO: POSSIBLE script reference conflict
        'Master.AddScriptReference(ConfigurationManager.AppSettings("ApplicationRoot") & "/ASD_Web_Handler.ashx?2;DOC, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null::DOC.DOC.Controls.Inmate.js")

        Master.AddScriptReference("~/Script/DOC.IMAS.AdditionalInfoCollector.js")
        Master.AddScriptReference("~/Script/DOC.IMAS.Confirmation.js")
        Master.AddScriptReference("~/Script/DOC.IMAS.ConfirmationRow.js")
        Master.AddScriptReference("~/Script/DOC.IMAS.ConfirmationHeader.js")
        Master.AddScriptReference("~/script/DOC.IMAS.Movement.Bed.js")
        Master.AddScriptReference("~/script/DOC.IMAS.Movement.BedDropBehavior.js")
        Master.AddScriptReference("~/script/DOC.IMAS.Movement.Bin.js")
        Master.AddScriptReference("~/script/DOC.IMAS.Movement.HousingUnit.js")
        Master.AddScriptReference("~/script/DOC.IMAS.Movement.ConfirmationHeader.js")
        Master.AddScriptReference("~/script/DOC.IMAS.Movement.ConfirmationRow.js")
        Master.AddScriptReference("~/script/DOC.IMAS.Movement.AdditionalInfoCollector.js")

        Master.TitleBar.Controls.Add(cmdSave)

        InmateValidator1.Refresh()
        MovementConfirmation1.Refresh()

        VerifyPassword1.Refresh()

        With InmateGroup1
            .Bins = Bins
            .HousingUnits = HousingUnits
            .Partner = InmateGroup1
            .Refresh()
        End With
        InmateGroups.Add(InmateGroup1.Control.ClientID)

        With InmateGroup2
            .Bins = Bins
            .HousingUnits = HousingUnits
            .Partner = InmateGroup2
            .Refresh()
        End With
        InmateGroups.Add(InmateGroup2.Control.ClientID)

        With HoldingBin1
            .Refresh()
        End With
        InmateGroups.Add(HoldingBin1.Control.ClientID)
    End Sub

   
   
End Class


Maybe this coding can more show what I am trying to do.

jjc9809
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 6

Accepted Solution

by:
esolve earned 500 total points
ID: 38809419
Theres a few things missing. What is this and where is it declared?

Control = rootElement
InstID = Master.InstID

I pressume the following comes from the master page. Do you have the masterpage set?

Master.TitleBar.ClientID
Master.LocationID

You will get and object reference not set error if you do not have a querystring (AIS) in the URL
Rather do this:

If Not Request.QueryString("AIS") = nothing
 AIS = Request.QueryString("AIS")
End if

There could be an error in this method

GetBinsAndHousingUnits()


This will also cause an error if you do not have this value in the web.config file
ConfigurationManager.AppSettings("ApplicationRoot")

The rest looks ok
0
 

Author Comment

by:jjc9809
ID: 38810154
Esolve,

Let me send you other files.  Yes, I do have a MasterPage Set.  Please find additional Web User Control Pages which go along with the Movement.ascx.  There is a folder named Movement.  Under this folder in the project, I have (1).  Confirmation.ascx, (2).  HoldingBin.ascx, (3).  InmateGroup.ascx, (4).  InmateGroup.ascx, (5).  InMateGroupSourceSelector.ascx., (6).  and of course Movement.ascx which I have already sent you.  There is one addtional file under the Movement folder,  which is (7).  ToolBar.ascx.  

Please find MasterPage.vb and Page.vb which is stored under a folder called Pages included as well.  I have attached the web configuration.Test.
Confirmation.ascx.doc
Confirmation.ascx.vb.doc
0
 

Author Comment

by:jjc9809
ID: 38810209
0
 
LVL 6

Expert Comment

by:esolve
ID: 38810523
jjc9809

You will have to  be more specific.

Each of these controls of yours inherits from other files.

eg. Inherits DOC.IMAS.MovementControl_BinAndHousingUnitList
eg. Inherits DOC.IMAS.AjaxUserControl

I cannot recreate your whole project with what you have provided me and it would not be possible to identify the error if I only have 10% of the objects.
0
 

Author Comment

by:jjc9809
ID: 38810795
Esolve,

I wonder if the entire project can be sent to you.  It is quite large.  I will just have to be more specific as you said.  Let me see what I can do further.
0
 

Author Comment

by:jjc9809
ID: 38832013
Esolve,

The error rendering errors does not affect the application running.  All User Controls and web pages appear to be running as they should.  I have been told to not concentrate on these errors and to just look at the Movement page and see what is wrong there with movement of an inmate to the control bin.

The main objective here is to upgrade and convert  the application to the 3.5 Dot Net Framework.  THe application has been published in the 2.0 Dot Net Framework with VS 2005  and is working fine in production.  However, VS 2008 R2 is going to be used now in the future.
I am getting these error rendering on the controls when the application in VS 2005 is converted to the VS 2008 R2 using the 3.5 Dot Net Framework.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now