I have a form that loops through the controls and builds a message off the input for an email. I added some RADinput controls , and they don't appear to be found. I can't figure out how to cast them either. Here is an excerpt:
Code Behind on a button click:
Prior to the RadInput controls, this worked perfectly. I need to add an elseIF for the rad controls - I am using a radtextbox and a radmaskedtextbox. I guess I am looking for DirectCast(ctrl, ?????).Text.
<tr> |
<td>Contact</td><td> |
<telerik:RadComboBox ID="cboContact" runat="server" Skin="Outlook" Width="200px"> |
<Items> |
<telerik:RadComboBoxItem Text="Rental Manager" Selected="true" Value="1" /> |
<telerik:RadComboBoxItem Text="Commanding Officer" Value="2"/> |
<telerik:RadComboBoxItem Text="Auxiliary President" Value="3" /> |
<telerik:RadComboBoxItem Text="Membership Officer" Value="4" /> |
<telerik:RadComboBoxItem Text="Service Officer" Value="5" /> |
</Items> |
</telerik:RadComboBox> |
</td> |
</tr> |
<tr> |
<td>Name</td><td><telerik:radtextbox Width="195px" id="txtName" runat="server" Label="" EmptyMessage="Your Name" Skin="Outlook" InvalidStyleDuration="100" LabelCssClass="radLabelCss_Outlook"> </telerik:radtextbox></td> |
</tr> |
<tr> |
<td>Phone Number</td><td><telerik:radmaskedtextbox skin="Outlook" runat="server" id="txtPhoneNumber" Mask="#########" EmptyMessage="" DisplayMask="###-##-####" DisplayPromptChar=" " /></td> |
</tr> |
<tr> |
<td>Address</td><td><telerik:radtextbox Width="300px" id="txtAddress" runat="server" TextMode="MultiLine" Label="" EmptyMessage="Your Address" Skin="Outlook"></telerik:radtextbox></td> |
</tr> |
<tr> |
Code Behind on a button click:
'build message body |
Dim pnl As Control = Master.FindControl("form1").FindControl("contentplaceholder1").FindControl("pnlForm") '.FindControl("pnlForm") |
Dim sMessageResponse As String = "" |
For Each ctrl As Control In pnl.Controls |
If TypeOf ctrl Is TextBox Then |
sMessageResponse += replaceText(ctrl.ID) & ": " & DirectCast(ctrl, TextBox).Text & vbCrLf & vbCrLf |
ElseIf TypeOf ctrl Is CheckBox Then |
sMessageResponse += replaceText(DirectCast(ctrl, CheckBox).Text) & ": " & Replace(Replace(DirectCast(ctrl, CheckBox).Checked, "False", "No"), "True", "Yes") & vbCrLf & vbCrLf |
ElseIf TypeOf ctrl Is DropDownList Then |
sMessageResponse += (replaceText(ctrl.ID) & ": " & DirectCast(ctrl, DropDownList).SelectedIndex & vbCrLf) |
ElseIf TypeOf ctrl Is RadioButtonList Or TypeOf ctrl Is RadioButtonList Then |
sMessageResponse += replaceText(ctrl.ID) & ": " & DirectCast(ctrl, RadioButtonList).SelectedValue & vbCrLf & vbCrLf |
Else |
End If |
' sMessageResponse += vbCrLf |
Next |
Mailmsg.Body = sMessageResponse |
Prior to the RadInput controls, this worked perfectly. I need to add an elseIF for the rad controls - I am using a radtextbox and a radmaskedtextbox. I guess I am looking for DirectCast(ctrl, ?????).Text.