3月 20, 2014

MVC Html對照

 @Html.Label("CheckBox:")<br>
    <input id="Checkbox1" name="group1" type="checkbox" value="yes" checked="checked"/>yes
    @Html.CheckBox("group1",false,new {id="Checkbox2",value="no"})
    <label for="checkbox1">no</label>
    <br>
    @Html.Label("RadioButton:")<br>
    <input id="RadioButton1" name="group2" type="radio" value="man"/>man
    @Html.RadioButton("group2","female", true, new { id="rd1"})female
    <br>
    @Html.Label("Textbox:")<br>
    First name: <input id="textbox1" name="name" type="text" value=""><br>
    Last name:  @Html.TextBox("name", "", new {id="textbox2" })
    <br>
    @Html.Label("Password:")<br>
    Password: <input id="password1" name="pwd" type="password">
    confim Password:@Html.Password("pwd", "", new {id="password2" })
    <br>
    @Html.Label("Hidden:")<br>
    <input id="Hidden1" name="hide" type="hidden" value="text" />
    @Html.Hidden("hide", "text", new { id="Hidden2"})
    <br>
    @Html.Label("TextArea:")<br>
    <textarea cols="20" id="TextArea1" name="TextArea1" rows="2"></textarea>
    @Html.TextArea("TextArea2")
    <br>
輸出結果:
<label for="CheckBox:">CheckBox:</label><br>
    <input id="Checkbox1" name="group1" type="checkbox" value="yes" checked="checked"/>yes
    <input id="Checkbox2" name="group1" type="checkbox" value="no" /><input name="group1" type="hidden" value="false" />
    <label for="checkbox1">no</label>
    <br>
    <label for="RadioButton:">RadioButton:</label><br>
    <input id="RadioButton1" name="group2" type="radio" value="man"/>man
    <input checked="checked" id="rd1" name="group2" type="radio" value="female" />female
    <br>
    <label for="Textbox:">Textbox:</label><br>
    First name: <input id="textbox1" name="name" type="text" value=""><br>
    Last name:  <input id="textbox2" name="name" type="text" value="" />
    <br>
    <label for="Password:">Password:</label><br>
    Password: <input id="password1" name="pwd" type="password">
    confim Password:<input id="password2" name="pwd" type="password" value="" />
    <br>
    <label for="Hidden:">Hidden:</label><br>
    <input id="Hidden1" name="hide" type="hidden" value="text" />
    <input id="Hidden2" name="hide" type="hidden" value="text" />
    <br>
    <label for="TextArea:">TextArea:</label><br>
    <textarea cols="20" id="TextArea1" name="TextArea1" rows="2"></textarea>
    <textarea cols="20" id="TextArea2" name="TextArea2" rows="2">
</textarea>
    <br>
而RadioButton的屬性name要一樣才能只選其中之一

沒有留言: