S
Shamin
Hi All,
I'm refering to the code in this article.
http://www.dnzone.com/ShowDetail.asp?NewsId=151
I'm trying to do the same in VB.NET and I'm having problems with
procedure ProcessSurveyResults. I was hoping to get some help on
fixing it. I would really appreciate.
Original C# Code:
while (itr.MoveNext()) {
// get the control name
string controlName = itr.Current.GetAttribute("name", "");
// append question information
sb.Append(controlName);
sb.Append(" : ");
// get the control
object ctrl = FindControl(controlName);
// append the correct filled out information
if (ctrl is TextBox) {
sb.Append(((TextBox)ctrl).Text);
}
if (ctrl is RadioButtonList) {
// the selected item might be null
if (((RadioButtonList)ctrl).SelectedItem != null) {
sb.Append(((RadioButtonList)ctrl).SelectedItem.Value);
}
}
sb.Append(Environment.NewLine);
}
VB.NET CODE:
While itr.MoveNext()
Dim controlName As String =
itr.Current.GetAttribute("name", "")
sb.Append(controlName)
sb.Append(" : ")
Dim ctrl As Object = FindControl(controlName)
If TypeOf ctrl Is TextBox Then
sb.Append(CType(ctrl, TextBox).Text)
End If
If TypeOf ctrl Is RadioButtonList Then
If Not (CType(ctrl, RadioButtonList).SelectedItem Is
Nothing) Then
sb.Append(CType(ctrl,
RadioButtonList).SelectedItem.Value)
End If
End If
sb.Append(Environment.NewLine)
End While
In VB when i debug the code inside the if statements (If TypeOf ctrl
Is ..... Then) is not executed. Any idea on what i'm doing wrong. It
works fine in C#.
I'm refering to the code in this article.
http://www.dnzone.com/ShowDetail.asp?NewsId=151
I'm trying to do the same in VB.NET and I'm having problems with
procedure ProcessSurveyResults. I was hoping to get some help on
fixing it. I would really appreciate.
Original C# Code:
while (itr.MoveNext()) {
// get the control name
string controlName = itr.Current.GetAttribute("name", "");
// append question information
sb.Append(controlName);
sb.Append(" : ");
// get the control
object ctrl = FindControl(controlName);
// append the correct filled out information
if (ctrl is TextBox) {
sb.Append(((TextBox)ctrl).Text);
}
if (ctrl is RadioButtonList) {
// the selected item might be null
if (((RadioButtonList)ctrl).SelectedItem != null) {
sb.Append(((RadioButtonList)ctrl).SelectedItem.Value);
}
}
sb.Append(Environment.NewLine);
}
VB.NET CODE:
While itr.MoveNext()
Dim controlName As String =
itr.Current.GetAttribute("name", "")
sb.Append(controlName)
sb.Append(" : ")
Dim ctrl As Object = FindControl(controlName)
If TypeOf ctrl Is TextBox Then
sb.Append(CType(ctrl, TextBox).Text)
End If
If TypeOf ctrl Is RadioButtonList Then
If Not (CType(ctrl, RadioButtonList).SelectedItem Is
Nothing) Then
sb.Append(CType(ctrl,
RadioButtonList).SelectedItem.Value)
End If
End If
sb.Append(Environment.NewLine)
End While
In VB when i debug the code inside the if statements (If TypeOf ctrl
Is ..... Then) is not executed. Any idea on what i'm doing wrong. It
works fine in C#.