zoukankan      html  css  js  c++  java
  • MVC4中给TextBoxFor设置默认值和属性(同时设置js事件)

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

    @Html.TextBoxFor(model => model.CustomerCode, new { Value=" 请输入您的客户号!",@style="240px;height:35px;",id="UserCode", @class="search_key_content"})
     
     
    给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>
  • 相关阅读:
    鞍点计算
    hdu-2546 饭卡 01背包
    判断2的个数
    1959: 图案打印
    1913: 成绩评估
    1908: 蟠桃记
    采药问题 01背包
    JAVA反射机制_获取Class中的构造函数
    JAVA反射机制_获取字节码文件对象
    tcp饭卡上两地分居克里斯丁
  • 原文地址:https://www.cnblogs.com/sjqq/p/7380035.html
Copyright © 2011-2022 走看看