Solved A critical error has occurred trying to access a user control from a user control

Posted on 2009-12-23
Last Modified: 2013-12-26
        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 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>
            <td class="SubHead" vAlign="top">Title:</td>
            <td><asp:Label ID="lblTitle" Runat="server" CssClass="Normal" EnableViewState="False" /></td>
            <td class="SubHead" vAlign="top">Date:</td>
            <td><asp:Label ID="lblDate" Runat="server" CssClass="Normal" EnableViewState="False" /></td>
            <td class="SubHead" vAlign="top">Summary:</td>
            <td><asp:Label ID="lblSummary" Runat="server" CssClass="Normal" EnableViewState="False" /></td>
      <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 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 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 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 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 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 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>


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()

        If sb.ToString() = "" Then
            Dim msg As New MailMessage("", "")
            msg.Subject = "" 'str3  'txtEmailSubject.Value
            msg.Body = "" 'Bodytext 'txtArea.Value

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

    End Sub
End Class
Question by:westdh
    1 Comment
    LVL 19

    Accepted Solution

    pls send the all error detail

    Featured Post

    Courses: Start Training Online With Pros, Today

    Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

    Join & Write a Comment

    Lync meeting or Lync conferencing is what many organizations would like to deploy to allow them save money. But companies are now giving up for various reasons, one of which is that they cannot join external meetings (non-federated company meetings)…
    Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

    755 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

    19 Experts available now in Live!

    Get 1:1 Help Now