Possible Duplicate:
Optimising asp.net vb code behind
I need to rewrite the below code :
If (storeSelected = 1) Then
tempCollector = tempCollector + "<br>" + "Department" + ": " + txt_panview3_ddinput1.SelectedItem.ToString
tempCollector = tempCollector + "<br>" + "Store" + ": " + txt_panview3_input2.Text + "<br>"
End If
If (areaSelected = 1) Then
tempCollector = tempCollector + "<br>" + "Area Name" + ": " + txt_panview0_ddinput1.SelectedItem.ToString
End If
If (headofficeSelected = 1) Then
tempCollector = tempCollector + "<br>" + "Department " + ": " + txt_panview1_ddinput1.SelectedItem.ToString
End If
If (regionSelected = 1) Then
tempCollector = tempCollector + "<br>" + "Region " + ": " + txt_panview2_ddinput1.SelectedItem.ToString
End If
'
If storeSelected() = 0 Then
tempCollector = tempCollector + "<p><b>" + lbl_viewTitle2.Text + "</b>"
tempCollector = tempCollector + "<br>" + lbl_view2_ManagersEmailAddress.Text + ": " + txt_view2_ManagersEmailAddress.Text
End If
Using the below rules:
Rule 1 :
i can use the below logic :
void AddControlText(StringBuilder builder, string label, ListBox listControl)
{
builder.Append("<br>");
builder.Append(label);
builder.Append(listControl.SelectedItem.Text);
}
This will reduce lots of code.
IF possible use the below rule also:
Rule 2:
i can use below logic:
If txt_panview3_ddlinput1.SelectedIndex > -1 Then
tempCollector.Append("<br>" & "Department" & ": " & txt_panview3_ddinput1.SelectedValue & "<br>" & "Store" & ": " & txt_panview3_input2.Text & "<br>")
End If
If txt_panview0_ddinput1.SelectedIndex > -1 Then
tempCollector.Append("<br>" & "Area Name" & ": " & txt_panview0_ddinput1.SelectedValue)
End If
If txt_panview1_ddinput1.SelectedIndex > -1 Then
tempCollector.Append("<br>" & "Department " & ": " & txt_panview1_ddinput1.SelectedValue)
End If
If txt_panview2_ddinput1.SelectedIndex > -1 Then
tempCollector.Append("<br>" & "Region " & ": " & txt_panview2_ddinput1.SelectedValue)
End If
If storeSelected() = 0 Then
tempCollector.Append("<p><b>" & lbl_viewTitle2.Text & "</b>")
tempCollector.Append("<br>" & lbl_view2_ManagersEmailAddress.Text & ": " & txt_view2_ManagersEmailAddress.Text)
End If
litResults.Text = tempCollector.ToString()
Please help me!