troubleshooting Question

asp.net A critical error has occurred trying to access a user control from a user control

Avatar of westdh
westdhFlag for United States of America asked on
Visual Basic ClassicMicrosoft ApplicationsMicrosoft Development
1 Comment1 Solution199 ViewsLast Modified:
     
        Dim u3 As UserControl = TryCast(FindControl("EventDetails"), UserControl)
        Dim a3 As Label = TryCast(u3.FindControl("lblTitle"), Label)
        'Dim str3 As String
        'str3 = "Event Title: " + a3.Text + "<BR>"

this is the user control I am trying to access EventDetails.ascx
===============================

<%@ Control Language="vb" Codebehind="EventDetails.ascx.vb" Inherits="i2Integration.Modules.EventReg.CustomControls.EventDetails" AutoEventWireup="true" Explicit="true" %>
<font class="SubHead">Event Information:</font>
<table id="tblForm" runat="server" cellpadding="3" summary="Event details layout table.">
      <tr id="rowID" runat="server" visible="false" EnableViewState="False">
            <td class="SubHead" vAlign="top">ID:</td>
            <td><asp:Label ID="lblEventID" Runat="server" CssClass="Normal" EnableViewState="False" /></td>
      </tr>
      <tr id="rowStatus" runat="server" EnableViewState="False">
            <td class="SubHead" vAlign="top">Status:</td>
            <td><asp:Label ID="lblStatus" Runat="server" CssClass="Normal" EnableViewState="False" /></td>
      </tr>
      <tr>
            <td class="SubHead" vAlign="top">Title:</td>
            <td><asp:Label ID="lblTitle" Runat="server" CssClass="Normal" EnableViewState="False" /></td>
      </tr>
      <tr>
            <td class="SubHead" vAlign="top">Date:</td>
            <td><asp:Label ID="lblDate" Runat="server" CssClass="Normal" EnableViewState="False" /></td>
      </tr>
      <tr>
            <td class="SubHead" vAlign="top">Summary:</td>
            <td><asp:Label ID="lblSummary" Runat="server" CssClass="Normal" EnableViewState="False" /></td>
      </tr>
      <tr id="rowDetails" runat="server" EnableViewState="False">
            <td class="SubHead" vAlign="top">Details:</td>
            <td><asp:Label ID="lblDetails" Runat="server" CssClass="Normal" EnableViewState="False" /></td>
      </tr>
      <tr id="rowViewStart" runat="server" EnableViewState="False">
            <td class="SubHead" vAlign="top">View Start:</td>
            <td><asp:Label ID="lblViewStart" Runat="server" CssClass="Normal" EnableViewState="False" /></td>
      </tr>
      <tr id="rowViewEnd" runat="server" EnableViewState="False">
            <td class="SubHead" vAlign="top">View End:</td>
            <td><asp:Label ID="lblViewEnd" Runat="server" CssClass="Normal" EnableViewState="False" /></td>
      </tr>
      <tr id="rowRegStart" runat="server" EnableViewState="False">
            <td class="SubHead" vAlign="top">Registration Begins:</td>
            <td><asp:Label ID="lblRegStart" Runat="server" CssClass="Normal" EnableViewState="False" /></td>
      </tr>
      <tr id="rowRegEnd" runat="server" EnableViewState="False">
            <td class="SubHead" vAlign="top">Registration Ends:</td>
            <td><asp:Label ID="lblRegEnd" Runat="server" CssClass="Normal" EnableViewState="False" /></td>
      </tr>
      <tr id="rowDiscount" runat="server" EnableViewState="False">
            <td class="SubHead" vAlign="top">Discount:</td>
            <td><asp:Label ID="lblDiscount" Runat="server" CssClass="Normal" EnableViewState="False" /></td>
      </tr>      
      <tr id="rowExport" runat="server" enableviewstate="false">
      <td class="SubHead" valign="top">Export to Outlook:</td>
      <td><asp:LinkButton ID="lnkExportToOutlook" runat="server" Text="Add to calendar"></asp:LinkButton></td>
      </tr>
</table>

===========================

this is the user control I am trying to access EventDetails from
-------------------------------

<%@ Control Language="VB"  CodeFile="EmailCompanyAttendees.ascx.vb" Inherits="DesktopModules_i2Integration___Events_controls_EmailCompanyAttendees" %>

 <asp:Button ID="Button1" runat="server"  EnableViewState="False" Text="Email event notices to registered attendees"
        ValidationGroup="EventRegAttendee" Width="312px" OnClick="EmailRegAttendeeNotices_Click" />
       
  -----------------------------------

Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Collections
Imports System.IO
Imports System.Text
Imports System.Xml
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Net.Mail

Partial Class DesktopModules_i2Integration___Events_controls_EmailCompanyAttendees
    Inherits System.Web.UI.UserControl

    Protected Sub EmailRegAttendeeNotices_Click(ByVal sender As Object, ByVal e As System.EventArgs)



        Dim u3 As UserControl = TryCast(FindControl("EventDetails"), UserControl)
        Dim a3 As Label = TryCast(u3.FindControl("lblTitle"), Label)
        'Dim str3 As String
        'str3 = "Event Title: " + a3.Text + "<BR>"
       
        'Dim Bodytext As String = str1 '+ str2 + str3 + str4 + str6 + str7 + str8
        'If str <> "" Then
        'Response.Write("Found lblTitle" + Str())
        'End If

        Dim sb As New StringBuilder()
        'For Each dr As DataRow In ctlAttendees.GetGrdAttendees.Rows()
        'sb.Append(ctlAttendees.grdAttendees.DataKeys(dr.RowIndex)("strBadgeName").ToString())
        'sb.Append(",")
        'Next

        If sb.ToString() = "" Then
            'Response.Write(sb.ToString())
            Dim msg As New MailMessage("dennis@dianewestdesign.com", "westdh@charter.net")
            msg.Subject = "" 'str3  'txtEmailSubject.Value
            msg.Body = "" 'Bodytext 'txtArea.Value

            Dim sc As New SmtpClient("smtp.dianewestdesign.com", 25)
            sc.Credentials = New Net.NetworkCredential("dennis@dianewestdesign.com", "programmer")
            sc.EnableSsl = False
            Try
                sc.Send(msg)
                Response.Write("<B>Email Has been sent successfully.</B>")
            Catch ex As Exception
                Response.Write(ex.Message)
            End Try
        End If

    End Sub
End Class
     
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 1 Comment.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros