2009-10-14 71 views
0

該代碼應該如何(asp.net標準)?屬性 - 標準明智

<label for="jobno">Job#</label> 
<input id="TextBox_JobID" name="jobno" runat="server"/> 
<input type="button" value="Show Job" class="fbutt" 
    id="Button_showJob" onserverclick="Button_showJob_ServerClick" 
    runat="server" /> 
</p> 
<p> 
    <asp:Label ID="Label_error" runat="server" class="error"></asp:Label></p> 

我認爲for屬性不好,或者沒有以正確的方式書寫?

回答

0

它也許應該讀

<label for="TextBox_JobID">Job#</label> 
1

for屬性的值必須與表單控件(如輸入元素或選擇元素)的id匹配,而不是名稱。

1

由於文本標記RUNAT = 「服務器」,我建議使用該控件的ClientID屬性:

<label for="<%=TextBox_JobID.ClientID%>">Job#</label> 

這時如果使用主頁面/用戶控件等,你可以確定它將始終包含正確的值。