write a C# code inside a javascript code, before body tag

  • Thread starter Thread starter Daniel Andrade
  • Start date Start date
D

Daniel Andrade

Hello,

How can I write a C# code inside a javascript code, before body tag, as
we wrote in classic asp?
(I have a code file separated with a lot of C# code)

I would like anything like this:

<head runat="server">

<style type="text/css">

<%

int x = 0;

// Load Data Table
DataTable rs = fnTabelaGradeCartas();

// Load the grid with recordset
foreach (DataRow cLinha in rs.Rows)
{

Response.Write (".active-column-" + x.ToString() +
" {width: 80px; text-align: right;}");

};

%>

.active-grid-column {border-right: 1px solid threedshadow;}
.active-grid-row {border-bottom: 1px solid
threedlightshadow;}
</style>

<title></title>
</head>
<body>
..
..
..


But the cod inside <% %> tags is ignorated :(
How could I write any c# code there?
Can I write this using the behind code or I must use like classic asp?

Please!
 
Put an asp:Literal tag in the page, and populate it from the code in
code-behind.

You might need to declare the reference to the control yourself, though,
as it's outside the form.
 
Back
Top