c# - ASP.NET MVC 3 Html helper not recognized -


for reason html helper not recognized.

@using system.data.sqlclient @using system.data <!doctype html> <html> <head>     <title>site visits</title> </head> <body>     <div>         @{               public string getsitevisits()             {                 datatable dt = new datatable();                 sqldataadapter sda = new sqldataadapter(                     "select numvisits tblsitevisits ipaddress='" + request.userhostaddress + "'",                     new sqlconnection("data source=*****;initial catalog=*****;persist security info=true;user id=*****;password=*****;multipleactiveresultsets=true"));                  sda.fill(dt);                  string table = "<table><tr>";                  foreach (datacolumn dc in dt.columns)                 {                        table += "<th>" + dc.columnname + "</th>";                 }                  table += "</tr>";                  foreach (datarow dr in dt.rows)                 {                     table += "<tr>";                      foreach (object o in dr.itemarray)                     {                         table += "<td>" + o.tostring() + "</td>";                        }                      table += "</tr>";                 }                  table += "</table>";                  return table;             }         }         <div>             @html.raw(getsitevisits())         </div>     </div> </body> </html> 

anyone know how fix it?

the way write html helpers in helper return string.

 <html>       <body>           <div>               @getsitevisits()          </div>           </body>   </html>   @helper getsitevisits()   {         @html.raw("hello");   } 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -