0 Replies - 1438 Views - Last Post: 26 October 2012 - 10:33 AM Rate Topic: -----

#1 rbflowers  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 48
  • Joined: 10-February 12

Creating divs in Razor function

Posted 26 October 2012 - 10:33 AM

Hey,
I'm trying to 'functionalize' the process of creating a bunch of divs to clean up my code.

Here's what I'm trying to do:

My program reads in an excel file and splits the lines into lists using ',' as the delimiter. I have a bunch of pages that need to display the same type of information, so I'm trying to write a function instead of having to rewrite the for loop 15-20 times:

   @functions { 
 void returnDrivers(List<string> list, List<string> colors){
        for(int i = 1; i < list.Count; i++){
            if(list[i] != ""){
                @:<div class="multiBreakdowns" id="@colors[i]">@list[i]</div>
            }   
        }
    }
}


First error I received was a missing ;

Quote

Compiler Error Message: CS1002: ; expected

Source Error:


Line 126: if(list[i] != ""){
Line 127: @:<div class="multiBreakdowns" id="@colors[i]">@list[i]</div>
Line 128: }
Line 129: }
Line 130: }



So I added it then got this error:

Quote

Compiler Error Message: CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement

Source Error:


Line 77: #line hidden
Line 78:
Line 79: item => new System.Web.WebPages.HelperResult(__razor_template_writer => {


Any idea what's going on?

Is This A Good Question/Topic? 0
  • +

Page 1 of 1