MVC4中给TextBoxFor设置默认值和属性(同时设置js事件)

例如:(特别注意在设置初始值的时候 Value 中的V要大写

@Html.TextBoxFor(model => model.CustomerCode, new { Value=" 请输入您的客户号!",@style="240px;height:35px;",})
 
 
给TextBoxFor设置默认值,当鼠标点击时默认值消失:
<script type="text/javascript">
    $(function () {
        $("#Content").html("在这里输入默认值");
    });
</script>
 
 <div class="label">@Html.LabelFor(model => model.Content)</div>
                <div class="ctrl">@Html.TextAreaFor(model => model.Content, new {style = "border:1px solid #6CABE7; 400px; height:150px;",onblur="if(this.innerHTML==''){this.innerHTML='在这里输入默认值';this.style.color='#D1D1D1'}",  onfocus="if(this.innerHTML=='在这里输入默认值'){this.innerHTML='';this.style.color='#000'}"})
                    @Html.ValidationMessageFor(model => model.Content)
                    @Html.DisplayDescriptionFor(model => model.Content)  <br /> 内心独白可以是一篇日记,一段让你心动的歌词,一句座右铭, 或者一个有意思的签名档,<br />但是不要少于20字,也不要超过1000字。 <br />
</div>