views:

38

answers:

3

How this code should be (asp.net standard)?

<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>

I think the for attribute is not ok, or not written in correct way?

+1  A: 

The value of the for attribute must match the id of a form control (such as an input element or a select element), not the name.

David Dorward
A: 

It should probably read

<label for="TextBox_JobID">Job#</label>
dove
A: 

As the textbox is marked runat="server", I would suggest using the ClientID property of the control:

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

Then if you use master pages/user controls etc, you can be sure it will always contain the right value.

Andrew Stevens