例如:(特别注意在设置初始值的时候 Value 中的V要大写)
@Html.TextBoxFor(model => model.CustomerCode, new { Value=" 请输入您的客户号!",@style="width: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; width: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>

MVC4中给TextBoxFor设置默认值和属性的更多相关文章

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

    例如:(特别注意在设置初始值的时候 Value 中的V要大写) @Html.TextBoxFor(model => model.CustomerCode, new { Value="  ...

  2. MVC中给TextBoxFor设置默认值和属性

    例如:(特别注意在设置初始值的时候 Value 中的V要大写) @Html.TextBoxFor(model => model.CustomerCode, new { Value=" ...

  3. Django的model中日期字段设置默认值的问题

    之前写过这样一个model: class MonthlyFeeMember(models.Model): worker = models.ForeignKey(Student, verbose_nam ...

  4. sqlite数据库中为字段设置默认值为当前时间

    开始 `creation_time` NUMERIC DEFAULT (datetime('now','localtime')), `update_time` NUMERIC DEFAULT (dat ...

  5. 《Entity Framework 6 Recipes》中文翻译系列 (14) -----第三章 查询之查询中设置默认值和存储过程返回多结果集

    翻译的初衷以及为什么选择<Entity Framework 6 Recipes>来学习,请看本系列开篇 3-6在查询中设置默认值 问题 你有这样一个用例,当查询返回null值时,给相应属性 ...

  6. Swift语言中为外部参数设置默认值可变参数常量参数变量参数输入输出参数

    Swift语言中为外部参数设置默认值可变参数常量参数变量参数输入输出参数 7.4.4  为外部参数设置默认值 开发者也可以对外部参数设置默认值.这时,调用的时候,也可以省略参数传递本文选自Swift1 ...

  7. winform中的dateTimePicker控件设置默认值为空

    winform中的dateTimePicker控件设置默认值为空   第一步:设置Format的属性值为“Custom” 第二步:设置CustomFormat的属性值为空,需要按一个空格键

  8. 【杂记】mysql 左右连接查询中的NULL的数据筛选问题,查询NULL设置默认值,DATE_FORMAT函数

    MySQL左右连接查询中的NULL的数据筛选问题 xpression 为 Null,则 IsNull 将返回 True:否则 IsNull 将返回 False. 如果 expression 由多个变量 ...

  9. vue+elementUI中单选框el-radio设置默认值和唯一标识某个单选框

    vue+elementUI中单选框el-radio设置默认值 如果后台返回的单选框的值是number:单选框的lable需要设置成 :lable='0';如下: <el-form-item la ...

随机推荐

  1. python之列表切片(slice)

    使用索引获取列表的元素(随机读取) 列表元素支持用索引访问,正向索引从0开始 colors=["red","blue","green"] c ...

  2. hadoop 2.4 伪分布式模式

    1.core-site.xml 在<configuration></configuration>中插入 <property> <name>fs.defa ...

  3. C/C++ 笔试、面试题目大汇总(二)

    一.找错题 试题1: void test1() { charstring[10]; char* str1 ="0123456789"; strcpy( string, str1 ) ...

  4. android判断pad还是手机

    第一种. Rect frame = new Rect(); getWindow().getDecorView().getWindowVisibleDisplayFrame(frame); if (fr ...

  5. SpringMVC+MyBatis(最新)

    目前主流的Web MVC框架,除了Struts这个主力 外,还有Spring MVC,主要是由于Spring MVC配置比较简单,使用起来也十分明了,非常灵活,与Spring 集成较好,对RESTfu ...

  6. linux pipe

    1. 函数说明 pipe(建立管道): 1) 头文件 #include<unistd.h> 2) 定义函数: int pipe(int filedes[2]); 3) 函数说明: pipe ...

  7. [LeetCode]题解(python):062 Unique path

    题目来源 https://leetcode.com/problems/unique-paths/ A robot is located at the top-left corner of a m x  ...

  8. 使用Aspose.Cell控件实现Excel高难度报表的生成(一)

    时光飞逝,生活.工作.业余研究总是在不停忙碌着,转眼快到月底,该月的博客文章任务未完,停顿回忆一下,总结一些经验以及好的东西出来,大家一起分享一下.本文章主要介绍报表的生成,基于Aspose.Cell ...

  9. 移动端a链接点击时取出背景色及边框

    a{blr:expression(this.onFocus=this.blur())} :focus{outline:0;} /*去掉a标签的虚线框,避免出现奇怪的选中区域*/*{-webkit-ta ...

  10. 【Netty学习】 ChannelInitializer 学习

    ChannelInitializer在Netty中是一个很重要的东西.也是4.x版本中用户接触比较多的一个类 它本身是继承ChannelInboundHandlerAdapter的.实现Channel ...