Question : How can I specify a table id when using  Response.Write?

I want to add CCS for a particular table that is built using Response.Write.  I add the id="" and got a error message that a valid expression is expected.  How can I specified the id for the table?  Thanks.  I'm using VS2008 and .net 3.5
        <%Response.Write("<td>")%>

Answer : How can I specify a table id when using  Response.Write?

This code is written by someone who did a lot of classic ASP coding and brought that style over to ASP.NET.

The more standard way to write this in .NET would be to move the code to the Page_Load event in a code behind, and work with the HTML table as a server-side HTML control.  Barring that at least remove the first 3 Response.Write calls you don't need them at all.

If you want to do the refactoring, your code would change to something like:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
THIS GOES IN THE ASPX PAGE:

Original Protocol Docs (Read Only)

THIS GOES IN THE ASPX.CS CODE BESIDE FILE IN THE PAGE_LOAD EVENT HANDLER: 'Modify all sql connection to internal address, RSASQLConnection or 192.168.1.30, in code and for Design of SqlDataSource1 Dim gcrc As String gcrc = Request.QueryString("gcrc") Session("gcrc") = gcrc 'Remove the following loc. This is a stub to debug locally Session("gcrc") = "1327" Dim filePath As String = Session("gcrc") & "*.*" '=================================================================================== 'CTU(Documents) '=================================================================================== Dim sqlConn As New SqlConnection(ConfigurationManager.ConnectionStrings("RsaConnectionString").ConnectionString) Dim sqlReader As SqlDataReader Dim sqlCmd As New SqlCommand("uspSelectCTUDocuments", sqlConn) With sqlCmd .CommandType = CommandType.StoredProcedure .Parameters.Add(New SqlParameter("@GCRC", SqlDbType.VarChar, 4)) .Parameters("@GCRC").Value = Session("gcrc") 'Session("currentProtocol") End With sqlConn.Open() sqlReader = sqlCmd.ExecuteReader() 'Response.Write("CTU Application Documents
") Dim row As HtmlTableRow Dim cell As HtmlTableCell While sqlReader.Read row = New HtmlTableRow() cell = New HtmlTableCell() cell.InnerHTML = "" + sqlReader("OriginalFileName") + "
" row.Cells.Add(cell) tblProtocolDocs.Rows.Add(row) End While sqlReader.Close() sqlCmd.Dispose() '=================================================================================== 'RSA Documents '=================================================================================== sqlCmd = New SqlCommand("uspSelectCTUInfo", sqlConn) With sqlCmd .CommandType = CommandType.StoredProcedure .Parameters.Add(New SqlParameter("@GCRC", SqlDbType.VarChar, 4)) .Parameters("@GCRC").Value = Session("gcrc") 'Session("currentProtocol") End With sqlReader = sqlCmd.ExecuteReader() sqlReader.Read()
Random Solutions  
 
programming4us programming4us