在Code Behind中创建<asp:hyperlink>,但在运行时不显示

时间:2017-08-29 00:31:11

标签: asp.net hyperlink

我正在动态创建我的网页,因为数据总是在变化。

我有一行包含带超链接的列。如果我在浏览器中查看而不使用我的代码,它可以很好地工作。当我尝试从后面的代码运行时,链接不显示。只有

的背面颜色

这是我创建行

背后的代码
strTable += "<tr id=""Row1_EventName"" style=""height: 19pt; width:100%"" runat=""server"">"
    strTable += "<td id=""Elem1_Name"" runat=""server"" colspan=""16"" class=""xl6620798"" style=""width:48.48%"">"
    strTable += "<asp:HyperLink runat=""server"" NavigateUrl=""" & strElem1_ChartLink & """ Text=""" & strElem1_Name & """ ToolTip=""" & strElem1_EventDirectionDesc & """ ForeColor=""Blue"" Width=""100%"" />"
    strTable += "</td>"
    strTable += "<td Class=""xl1520798"" style=""width:3.03%""></td>"

    If strElem2_Name <> "" Then
        strTable += "<td id=""Elem2_Name"" runat=""server"" colspan=""16"" class=""xl6620798"" style=""width:48.48%"">"
        strTable += "<asp:HyperLink runat = ""server"" NavigateUrl=""" & strElem2_ChartLink & """ Text=""" & strElem2_Name & """ ToolTip=""" & strElem2_EventDirectionDesc & """ ForeColor=""Blue"" Width=""100%"" />"
        strTable += "</td>"
    Else
        strTable += "<td colspan=""16"" class=""xl1520798"" style=""width:48.48%""></td>"
    End If

    strTable += "</tr>"

css代码如下:

.xl1520798 {
        padding-top: 1px;
        padding-right: 1px;
        padding-left: 1px;
        color: black;
        font-size: 9.0pt;
        font-weight: 400;
        font-style: normal;
        text-decoration: none;
        vertical-align: bottom;
        white-space: nowrap;
    }

    .xl6620798 {
        padding-top: 1px;
        padding-right: 1px;
        padding-left: 1px;
        color: black;
        font-size: 9.0pt;
        font-weight: 400;
        font-style: normal;
        text-decoration: none;
        text-align: center;
        vertical-align: bottom;
        background: #B8CCE4;
        white-space: nowrap;
    }

以下是我运行页面时的样子:

Hyperlink not showing

0 个答案:

没有答案