2013-08-27 42 views
-1

here'is我的HTML:服務器標籤不規範

<asp:Label ID="EmployeeIDlbl" runat="server" Text="<%# GetLabelCaption("Judges", "Employee Number",CaptionType.EditLabel) %>"></asp:Label> 

其中:CaptionStyle是我以前創建Enumerator,並GetLabelCaption函數返回一個字符串從SQL數據庫中獲取。

我想知道錯誤在哪裏?

+0

您使用數據綁定表達式'<%#',但你可能需要簡單的回聲'<%=' – Tommi

+0

@Tommi - 你不能用'<%='服務器控件。你可以使用'<%#'。但爲什麼不使用代碼隱藏呢? –

+0

確實。沒有看到它是runat =「服務器」。 __爲什麼不使用代碼隱藏而不是_有些人喜歡聲明式風格。我不同意他們,但這是他們的權利。 – Tommi

回答

2

,你提到的文字如下把單引號:

<asp:Label ID="EmployeeIDlbl" runat="server" Text='<%# GetLabelCaption("Judges", "Employee Number",CaptionType.EditLabel) %>'></asp:Label> 

這將工作

2

你需要把文本內容在單引號(' ')代替雙引號(" ")。因此,嘗試這種

<asp:Label ID="EmployeeIDlbl" runat="server" Text='<%# GetLabelCaption("Judges", "Employee Number",CaptionType.EditLabel) %>'></asp:Label>