How do I return form objects that are not null as a receipt?

I have a web application that has about 50 or more fields split up into several panels and I am using them in a asp:wizard across several steps. At the end of the form I want to create a "Here is what you requested Label1.text...." according to whatever the user requested without recreating several labels and binding the text of each box to label manualy. Here is what I have tried in attempt to call a list of textboxes that are not null in the form, but it throws an exception because of the exclamation.

var requested = this.Controls.OfType<TextBox>()
                          .Where(txt => string.!IsNullOrWhiteSpace(txt.Text));

    foreach (var textBox in requested)
    {
        Response.Write(requested);
    }
Jon Skeet
people
quotationmark

It's because that's invalid syntax - you want to call string.IsNullOrWhiteSpace and invert the result:

.Where(txt => !string.IsNullOrWhiteSpace(txt.Text))

Currently you've got the ! in the middle of the method invocation, which is what's wrong.

(Then be aware that currently you're trying to write out the textbox itself - I suspect you don't want to do that. But you'll find that out when you've got past the syntax error.)

people

See more on this question at Stackoverflow