westdh
asked on
Need to know how to access a user control (.ascx) to build a StringBuilder() in another User Control
Here is some data on my compile error ->
so here is some more data on this line that is giving me an error located in register.ascx
--> For Each dg As DataList In ctlAttendees.grdAttendees. Rows
Error# 'i2Integration.Modules.Eve ntReg.Cust omControls .AttendeeL ist.Protec ted WithEvents grdAttendees As System.Web.UI.WebControls. DataGrid' is not accessible in this context because it is 'Protected'. C:\Documents and Settings\Dennis West\Local Settings\Temp\VWDWebCache\ cmaanorcal events.com \DesktopMo dules\i2In tegration - Events\user\Register.ascx
this is my -> Register.ascx User control
========================== ========== ========== ======
<%@ Control Language="vb" Codebehind="Register.ascx. vb" Inherits="i2Integration.Mo dules.Even tReg.Regis ter"
AutoEventWireup="false" Explicit="true" %>
<%@ Register TagPrefix="events" TagName="EventDetails" Src="../controls/EventDeta ils.ascx" %>
<%@ Register TagPrefix="events" TagName="AttendeeList" Src="../controls/AttendeeL ist.ascx" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.Sql Client" %>
<%@ Import Namespace="System.Configur ation" %>
<%@ Import Namespace="System.Collecti ons" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Web.Secu rity" %>
<%@ Import Namespace="System.Web.UI" %>
<%@ Import Namespace="System.Web.UI.W ebControls " %>
<%@ Import Namespace="System.Web.UI.W ebControls .WebParts" %>
<%@ Import Namespace="System.Web.UI.H tmlControl s" %>
<%@ Import Namespace="System.Net.Mail " %>
<%@ Import Namespace="System.Web.UI.C ontrol" %>
<%@ Import Namespace="System.Net.Mail " %>
<script runat="server" language="vb">
Protected Sub EmailRegAttendeeNotices_Cl ick(ByVal sender As Object, ByVal e As EventArgs)
Dim sb As New StringBuilder()
Dim x As UserControl = TryCast(FindControl("Atten deeList"), UserControl)
error-> For Each dr As DataRow In ctlAttendees.grdAttendees. Rows
sb.Append(ctlAttendees.grd Attendees. DataKeys(d r.RowIndex ) ("strBadgeName").ToString( ))
sb.Append(",")
Next
If sb.ToString() <> "" Then
'Response.Write(sb.ToStrin g())
Dim msg As New MailMessage("dennis@xxxxxx xxxxxx.com ", sb.ToString())
msg.Subject = "test" 'txtEmailSubject.Value
msg.Body = "test" 'txtArea.Value
Dim sc As New SmtpClient("smtp.xxxxxx.co m", 25)
sc.Credentials = New Net.NetworkCredential("dxx xx@dianewe stdesign.c om", "xxxxxxxxxx")
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
</script>
<asp:Label ID="lblError" runat="server" CssClass="NormalRed" EnableViewState="false"
Visible="false" />
<asp:Panel ID="pnlMain" runat="server">
<events:EventDetails id="ctlEvent" runat="server" ShowDetails="false" ShowDiscount="true" />
<br />
* If you are registering and today's date is within 3 days of the event date,
add a $10.00 late fee.<br />
Please select the appropriate member or non-member late Fee.<br />
<table border="0" cellspacing="0" cellpadding="2" summary="Layout design table."
id="tblAddAttendee" runat="server">
<tr class="SubHead">
<td>Attendee Name<br />
First & Last Name:</td>
<td>
Attendee Email:</td>
<td>
Attendee Type and Cost:</td>
<td>
</td>
</tr>
<tr>
<td>
<asp:TextBox ID="txtAddUserTypeName" runat="server" CssClass="NormalTextbox" EnableViewState="False" />
</td>
<td>
<asp:TextBox ID="txtAddUserTypeBadgeNam e" runat="server" CssClass="NormalTextbox"
EnableViewState="False" />
</td>
<td>
<asp:DropDownList ID="lstUserTypes" runat="server" CssClass="NormalTextbox" EnableViewState="False" />
</td>
<td>
<asp:Button ID="cmdAddUserType" runat="server" Text="Add Attendee(s)" EnableViewState="False"
CssClass="CommandButton" ValidationGroup="EventRegA ttendee" />
</td>
</tr>
</table>
<font class="SubHead">
<br />
Attendees:</font>
<br />
<events:AttendeeList ID="ctlAttendees" runat="server" />
<br />
<asp:Label ID="lblAttendeeLimitReache d" runat="server" CssClass="SubHead"
resourcekey="AttendeeLimit Reached" Visible="false"></asp:Labe l>
<asp:Label ID="lblAttendeesLeftMessag e" runat="server" CssClass="SubHead"></asp:L abel>
<asp:Button ID="Button1" runat="server" CssClass="CommandButton"
EnableViewState="False" Text="Email event notices to registered attendees"
ValidationGroup="EventRegA ttendee" Width="269px" OnClick="EmailRegAttendeeN otices()" />
<br />
<br />
<font class="SubHead">
<label for='<%= txtNeeds.ClientID %>'>
Special Needs:</label>
</font>
<br />
<asp:TextBox ID="txtNeeds" runat="server" Height="100" Width="600" TextMode="MultiLine" />
<br />
<font class="SubHead">
<label for='<%= txtNotes.ClientID %>'>
Comments:</label>
</font>
<br />
<asp:TextBox ID="txtNotes" runat="server" Height="100" Width="600" TextMode="MultiLine" />
<br />
<font class="SubHead">
<label for='<%= radPayMethod.ClientID %>_0'>
Payment Method:</label></font><asp :RadioButt onList ID="radPayMethod" runat="server" AutoPostBack="False" RepeatDirection="Horizonta l"
CssClass="Normal" />
<asp:Label ID="lblPayLaterNote" runat="server" CssClass="Normal" EnableViewState="False" />
<br />
<asp:Label ID="lblDonation" runat="server" resourcekey="DonationLabel " CssClass="SubHead"></asp:L abel>
<asp:TextBox ID="txtDonation" runat="server"></asp:TextB ox>
<asp:Label ID="lblDonationMessage" runat="server" resourcekey="DonationMessa geLabel"
CssClass="SubHead"></asp:L abel>
<asp:RegularExpressionVali dator ID="valDonation" runat="server" resourcekey="DonationValid ator"
ControlToValidate="txtDona tion" ValidationExpression="^\d+ (?:\.\d{0, 2})?$"></a sp:Regular Expression Validator>
<br />
<br />
</asp:Panel>
<asp:HyperLink class="CommandButton CancelButton" ID="lnkCancel" runat="server" BorderStyle="none"
Text="Cancel" EnableViewState="False" />
<asp:LinkButton class="CommandButton SubmitButton" ID="cmdSubmit" runat="server" BorderStyle="none"
Text="Next" CausesValidation="False" EnableViewState="False" />
this is my attendee control:
========================== =====
<%@ Control Language="vb" Codebehind="AttendeeList.a scx.vb" Inherits="i2Integration.Mo dules.Even tReg.Custo mControls. AttendeeLi st"
AutoEventWireup="false" Explicit="true" %>
<asp:Label ID="lblNoRecords" runat="server" resourcekey="NoAttendeesMe ssage" CssClass="Normal"
EnableViewState="False" Visible="False" Text="No attendees found."></asp:Label><br />
<asp:DataGrid ID="grdAttendees" runat="server" summary="Attendees design table."
CellPadding="4" CellSpacing="0" AllowPaging="False" AllowSorting="False" AutoGenerateColumns="False "
ShowHeader="True" ShowFooter="True" HeaderStyle-CssClass="SubH ead" ItemStyle-CssClass="Normal "
FooterStyle-CssClass="SubH ead" FooterStyle-HorizontalAlig n="Right" >
<Columns>
<asp:BoundColumn DataField="intRegistration UserID" HeaderText="IDColumn" FooterText=""
Visible="false" ReadOnly="True" />
<asp:BoundColumn DataField="strRegistration UserName" HeaderText="NameColumn" FooterText="" />
<asp:BoundColumn DataField="strBadgeName" HeaderText="NameOnBadgeCol umn" FooterText="" />
<asp:BoundColumn DataField="strUserTypeName " HeaderText="TypeColumn" FooterText="TOTAL:"
ReadOnly="True" />
<asp:BoundColumn DataField="fltRegistration UserCost" HeaderText="CostColumn" ReadOnly="True"
DataFormatString="{0:$#,## 0.00}" ItemStyle-HorizontalAlign= "Right" FooterText="" />
<asp:ButtonColumn ButtonType="LinkButton" CommandName="remove" HeaderText="RemoveColumn"
Text="[Remove]" />
</Columns>
</asp:DataGrid>
so here is some more data on this line that is giving me an error located in register.ascx
--> For Each dg As DataList In ctlAttendees.grdAttendees.
Error# 'i2Integration.Modules.Eve
this is my -> Register.ascx User control
==========================
<%@ Control Language="vb" Codebehind="Register.ascx.
AutoEventWireup="false" Explicit="true" %>
<%@ Register TagPrefix="events" TagName="EventDetails" Src="../controls/EventDeta
<%@ Register TagPrefix="events" TagName="AttendeeList" Src="../controls/AttendeeL
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.Sql
<%@ Import Namespace="System.Configur
<%@ Import Namespace="System.Collecti
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Web.Secu
<%@ Import Namespace="System.Web.UI" %>
<%@ Import Namespace="System.Web.UI.W
<%@ Import Namespace="System.Web.UI.W
<%@ Import Namespace="System.Web.UI.H
<%@ Import Namespace="System.Net.Mail
<%@ Import Namespace="System.Web.UI.C
<%@ Import Namespace="System.Net.Mail
<script runat="server" language="vb">
Protected Sub EmailRegAttendeeNotices_Cl
Dim sb As New StringBuilder()
Dim x As UserControl = TryCast(FindControl("Atten
error-> For Each dr As DataRow In ctlAttendees.grdAttendees.
sb.Append(ctlAttendees.grd
sb.Append(",")
Next
If sb.ToString() <> "" Then
'Response.Write(sb.ToStrin
Dim msg As New MailMessage("dennis@xxxxxx
msg.Subject = "test" 'txtEmailSubject.Value
msg.Body = "test" 'txtArea.Value
Dim sc As New SmtpClient("smtp.xxxxxx.co
sc.Credentials = New Net.NetworkCredential("dxx
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
</script>
<asp:Label ID="lblError" runat="server" CssClass="NormalRed" EnableViewState="false"
Visible="false" />
<asp:Panel ID="pnlMain" runat="server">
<events:EventDetails id="ctlEvent" runat="server" ShowDetails="false" ShowDiscount="true" />
<br />
* If you are registering and today's date is within 3 days of the event date,
add a $10.00 late fee.<br />
Please select the appropriate member or non-member late Fee.<br />
<table border="0" cellspacing="0" cellpadding="2" summary="Layout design table."
id="tblAddAttendee" runat="server">
<tr class="SubHead">
<td>Attendee Name<br />
First & Last Name:</td>
<td>
Attendee Email:</td>
<td>
Attendee Type and Cost:</td>
<td>
</td>
</tr>
<tr>
<td>
<asp:TextBox ID="txtAddUserTypeName" runat="server" CssClass="NormalTextbox" EnableViewState="False" />
</td>
<td>
<asp:TextBox ID="txtAddUserTypeBadgeNam
EnableViewState="False" />
</td>
<td>
<asp:DropDownList ID="lstUserTypes" runat="server" CssClass="NormalTextbox" EnableViewState="False" />
</td>
<td>
<asp:Button ID="cmdAddUserType" runat="server" Text="Add Attendee(s)" EnableViewState="False"
CssClass="CommandButton" ValidationGroup="EventRegA
</td>
</tr>
</table>
<font class="SubHead">
<br />
Attendees:</font>
<br />
<events:AttendeeList ID="ctlAttendees" runat="server" />
<br />
<asp:Label ID="lblAttendeeLimitReache
resourcekey="AttendeeLimit
<asp:Label ID="lblAttendeesLeftMessag
<asp:Button ID="Button1" runat="server" CssClass="CommandButton"
EnableViewState="False" Text="Email event notices to registered attendees"
ValidationGroup="EventRegA
<br />
<br />
<font class="SubHead">
<label for='<%= txtNeeds.ClientID %>'>
Special Needs:</label>
</font>
<br />
<asp:TextBox ID="txtNeeds" runat="server" Height="100" Width="600" TextMode="MultiLine" />
<br />
<font class="SubHead">
<label for='<%= txtNotes.ClientID %>'>
Comments:</label>
</font>
<br />
<asp:TextBox ID="txtNotes" runat="server" Height="100" Width="600" TextMode="MultiLine" />
<br />
<font class="SubHead">
<label for='<%= radPayMethod.ClientID %>_0'>
Payment Method:</label></font><asp
CssClass="Normal" />
<asp:Label ID="lblPayLaterNote" runat="server" CssClass="Normal" EnableViewState="False" />
<br />
<asp:Label ID="lblDonation" runat="server" resourcekey="DonationLabel
<asp:TextBox ID="txtDonation" runat="server"></asp:TextB
<asp:Label ID="lblDonationMessage" runat="server" resourcekey="DonationMessa
CssClass="SubHead"></asp:L
<asp:RegularExpressionVali
ControlToValidate="txtDona
<br />
<br />
</asp:Panel>
<asp:HyperLink class="CommandButton CancelButton" ID="lnkCancel" runat="server" BorderStyle="none"
Text="Cancel" EnableViewState="False" />
<asp:LinkButton class="CommandButton SubmitButton" ID="cmdSubmit" runat="server" BorderStyle="none"
Text="Next" CausesValidation="False" EnableViewState="False" />
this is my attendee control:
==========================
<%@ Control Language="vb" Codebehind="AttendeeList.a
AutoEventWireup="false" Explicit="true" %>
<asp:Label ID="lblNoRecords" runat="server" resourcekey="NoAttendeesMe
EnableViewState="False" Visible="False" Text="No attendees found."></asp:Label><br />
<asp:DataGrid ID="grdAttendees" runat="server" summary="Attendees design table."
CellPadding="4" CellSpacing="0" AllowPaging="False" AllowSorting="False" AutoGenerateColumns="False
ShowHeader="True" ShowFooter="True" HeaderStyle-CssClass="SubH
FooterStyle-CssClass="SubH
<Columns>
<asp:BoundColumn DataField="intRegistration
Visible="false" ReadOnly="True" />
<asp:BoundColumn DataField="strRegistration
<asp:BoundColumn DataField="strBadgeName" HeaderText="NameOnBadgeCol
<asp:BoundColumn DataField="strUserTypeName
ReadOnly="True" />
<asp:BoundColumn DataField="fltRegistration
DataFormatString="{0:$#,##
<asp:ButtonColumn ButtonType="LinkButton" CommandName="remove" HeaderText="RemoveColumn"
Text="[Remove]" />
</Columns>
</asp:DataGrid>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have put this into inline code in Attendees.ascx
Function GetGrdAttendees() As Integer ... then found that integer is not accepatable
Return grdAttendees
End Function
So--- I change it to read..this seem to work
Function GetGrdAttendees() As DataGrid
Return grdAttendees
End Function
But I do not see how this function is accessed
========================== ========== ==
And I changed this: still Name 'grdAttendees' is not declared
Dim sb As New StringBuilder()
For Each dr As DataRow In ctlAttendees.GetGrdAttende es.Rows()
sb.Append(ctlAttendees.grd Attendees. DataKeys(d r.RowIndex )("strBadg eName").To String())
sb.Append(",")
Next
Function GetGrdAttendees() As Integer ... then found that integer is not accepatable
Return grdAttendees
End Function
So--- I change it to read..this seem to work
Function GetGrdAttendees() As DataGrid
Return grdAttendees
End Function
But I do not see how this function is accessed
==========================
And I changed this: still Name 'grdAttendees' is not declared
Dim sb As New StringBuilder()
For Each dr As DataRow In ctlAttendees.GetGrdAttende
sb.Append(ctlAttendees.grd
sb.Append(",")
Next
Can you tell me how ctlAttendees is defined?
I thought it contains a list of the user controls.. is it a list?
If so, ctlAttendees.GetGrdAttende es must change to ctlAttendees(idx).GetGrdAt tendees
where idx is the index of the required attendee control.
I thought it contains a list of the user controls.. is it a list?
If so, ctlAttendees.GetGrdAttende
where idx is the index of the required attendee control.
ASKER
<asp:DataGrid ID="grdAttendees" runat="server" summary="Attendees design table."
CellPadding="4" CellSpacing="0" AllowPaging="False" AllowSorting="False" AutoGenerateColumns="False "
ShowHeader="True" ShowFooter="True" HeaderStyle-CssClass="SubH ead" ItemStyle-CssClass="Normal "
FooterStyle-CssClass="SubH ead" FooterStyle-HorizontalAlig n="Right" >
<Columns>
<asp:BoundColumn DataField="intRegistration UserID" HeaderText="IDColumn" FooterText=""
Visible="false" ReadOnly="True" />
<asp:BoundColumn DataField="strRegistration UserName" HeaderText="NameColumn" FooterText="" />
<asp:BoundColumn DataField="strBadgeName" HeaderText="NameOnBadgeCol umn" FooterText="" />
<asp:BoundColumn DataField="strUserTypeName " HeaderText="TypeColumn" FooterText="TOTAL:"
ReadOnly="True" />
<asp:BoundColumn DataField="fltRegistration UserCost" HeaderText="CostColumn" ReadOnly="True"
DataFormatString="{0:$#,## 0.00}" ItemStyle-HorizontalAlign= "Right" FooterText="" />
<asp:ButtonColumn ButtonType="LinkButton" CommandName="remove" HeaderText="RemoveColumn"
Text="[Remove]" />
CellPadding="4" CellSpacing="0" AllowPaging="False" AllowSorting="False" AutoGenerateColumns="False
ShowHeader="True" ShowFooter="True" HeaderStyle-CssClass="SubH
FooterStyle-CssClass="SubH
<Columns>
<asp:BoundColumn DataField="intRegistration
Visible="false" ReadOnly="True" />
<asp:BoundColumn DataField="strRegistration
<asp:BoundColumn DataField="strBadgeName" HeaderText="NameOnBadgeCol
<asp:BoundColumn DataField="strUserTypeName
ReadOnly="True" />
<asp:BoundColumn DataField="fltRegistration
DataFormatString="{0:$#,##
<asp:ButtonColumn ButtonType="LinkButton" CommandName="remove" HeaderText="RemoveColumn"
Text="[Remove]" />
Sorry you posted grdAttendees, I need ctlAttendees declaration and how this object is filled?
Note: It should be on your base page (i2Integration.Modules.Eve ntReg.Cust omControls .AttendeeL ist)
Note: It should be on your base page (i2Integration.Modules.Eve
ASKER
ok here it is...........
<%@ Control Language="vb" Codebehind="AttendeeList.a scx.vb" Inherits="i2Integration.Mo dules.Even tReg.Custo mControls. AttendeeLi st"
AutoEventWireup="false" Explicit="true" %>
<asp:Label ID="lblNoRecords" runat="server" resourcekey="NoAttendeesMe ssage" CssClass="Normal"
EnableViewState="False" Visible="False" Text="No attendees found."></asp:Label><br />
<asp:DataGrid ID="grdAttendees" runat="server" summary="Attendees design table."
CellPadding="4" CellSpacing="0" AllowPaging="False" AllowSorting="False" AutoGenerateColumns="False "
ShowHeader="True" ShowFooter="True" HeaderStyle-CssClass="SubH ead" ItemStyle-CssClass="Normal "
FooterStyle-CssClass="SubH ead" FooterStyle-HorizontalAlig n="Right" >
<Columns>
<asp:BoundColumn DataField="intRegistration UserID" HeaderText="IDColumn" FooterText=""
Visible="false" ReadOnly="True" />
<asp:BoundColumn DataField="strRegistration UserName" HeaderText="NameColumn" FooterText="" />
<asp:BoundColumn DataField="strBadgeName" HeaderText="NameOnBadgeCol umn" FooterText="" />
<asp:BoundColumn DataField="strUserTypeName " HeaderText="TypeColumn" FooterText="TOTAL:"
ReadOnly="True" />
<asp:BoundColumn DataField="fltRegistration UserCost" HeaderText="CostColumn" ReadOnly="True"
DataFormatString="{0:$#,## 0.00}" ItemStyle-HorizontalAlign= "Right" FooterText="" />
<asp:ButtonColumn ButtonType="LinkButton" CommandName="remove" HeaderText="RemoveColumn"
Text="[Remove]" />
</Columns>
</asp:DataGrid>
<%@ Control Language="vb" Codebehind="AttendeeList.a
AutoEventWireup="false" Explicit="true" %>
<asp:Label ID="lblNoRecords" runat="server" resourcekey="NoAttendeesMe
EnableViewState="False" Visible="False" Text="No attendees found."></asp:Label><br />
<asp:DataGrid ID="grdAttendees" runat="server" summary="Attendees design table."
CellPadding="4" CellSpacing="0" AllowPaging="False" AllowSorting="False" AutoGenerateColumns="False
ShowHeader="True" ShowFooter="True" HeaderStyle-CssClass="SubH
FooterStyle-CssClass="SubH
<Columns>
<asp:BoundColumn DataField="intRegistration
Visible="false" ReadOnly="True" />
<asp:BoundColumn DataField="strRegistration
<asp:BoundColumn DataField="strBadgeName" HeaderText="NameOnBadgeCol
<asp:BoundColumn DataField="strUserTypeName
ReadOnly="True" />
<asp:BoundColumn DataField="fltRegistration
DataFormatString="{0:$#,##
<asp:ButtonColumn ButtonType="LinkButton" CommandName="remove" HeaderText="RemoveColumn"
Text="[Remove]" />
</Columns>
</asp:DataGrid>
Sorry your last post does not have it, I need ctlAttendees declaration and how this object is filled?
Note: how is i2Integration.Modules.Even tReg.Custo mControls. AttendeeLi st declared?
AttendeeList.ascx.vb does not have what we need, look for the base class (
Inherits="i2Integration.Mo dules.Even tReg.Custo mControls. AttendeeLi st")
Note: how is i2Integration.Modules.Even
AttendeeList.ascx.vb does not have what we need, look for the base class (
Inherits="i2Integration.Mo
You either need to create a get method or a property to surface this value in code behind.
public DataGrid GetGrdAttendees()
{
return grdAttendees;
}