• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 184
  • Last Modified:

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

     
        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
     
0
westdh
Asked:
westdh
1 Solution
 
Melih SARICACommented:
pls send the all error detail
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now