惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

云风的 BLOG
云风的 BLOG
The Last Watchdog
The Last Watchdog
L
Lohrmann on Cybersecurity
P
Proofpoint News Feed
I
Intezer
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Cisco Talos Blog
Cisco Talos Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Threat Research - Cisco Blogs
S
Schneier on Security
罗磊的独立博客
AWS News Blog
AWS News Blog
S
Securelist
J
Java Code Geeks
月光博客
月光博客
V
Vulnerabilities – Threatpost
博客园 - 【当耐特】
有赞技术团队
有赞技术团队
G
GRAHAM CLULEY
Project Zero
Project Zero
H
Hackread – Cybersecurity News, Data Breaches, AI and More
D
DataBreaches.Net
The Hacker News
The Hacker News
Know Your Adversary
Know Your Adversary
The GitHub Blog
The GitHub Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Scott Helme
Scott Helme
博客园 - Franky
S
Security Affairs
Cyberwarzone
Cyberwarzone
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Forbes - Security
Forbes - Security
K
Kaspersky official blog
Martin Fowler
Martin Fowler
Schneier on Security
Schneier on Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
宝玉的分享
宝玉的分享
腾讯CDC
Application and Cybersecurity Blog
Application and Cybersecurity Blog
G
Google Developers Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
美团技术团队
MyScale Blog
MyScale Blog
L
LangChain Blog
V
V2EX
N
News | PayPal Newsroom
N
News and Events Feed by Topic
aimingoo的专栏
aimingoo的专栏
Blog — PlanetScale
Blog — PlanetScale
IT之家
IT之家

博客园 - 飞翔的天空

sp.net core部署到iis中出现 HTTP Error 502.5 - Process Failure 的解决办法 aspnet zero Swagger 不出现Authorize按钮的解决办法 Js获取当前日期时间及其它操作 js阿拉伯数字转中文大写 php学习点滴 excel合并单元格内容 EXCEL公式以指定分隔符从右往左截取字符 drupal学习FAQ drupal模块简介 Zxing中文乱码的简单解决办法 easyUI MVC3一些注意的东东(4) orchard模块编写的错误及其解决办法 orchard文档之-orchard工作原理 orchard文档之-搜索和索引 orchard文档之-更新站点到新的orchard版本 orchard文档之-创建自定义表单 准备把orchard的自己认为重要的文档翻译一遍 orchard文档之-理解内容处理器 orchard文档之-理解数据访问
js中三目运算及readonly的解决办法
飞翔的天空 · 2013-07-08 · via 博客园 - 飞翔的天空

我的一个需求,判断一个资产的代码,如果没有代码,可以编辑,如果有,只读。

首先判断资产的有无:@Model.AssetCode==null,结果@Model.AssetCode为空的时候语法错误,最后想了个办法,取长度判断@Model.AssetCode.Length==0

@{ bool isAssertCodeNull=@Model.AssetCode.Length==0?false:true;}

然后传值到html中  

 <input id="AssetCode" value="@Model.AssetCode"  readonly=@isAssertCodeNull />

但当AssetCode为空的时候还是不能编辑。用来,只要 input 有readdonly属性,不管其值是什么,都不可编辑。

最后的解决办法,在js中,判断AssetCode的长度是否为0,是,移除readonly属性,问题解决

   if(@Model.AssetCode.Length==0)
    {
        $('#AssetCode').removeAttr('readonly');
    }