如何为基于单击行为的ASP MVC设置文本框 [英] How to set text box for based on click behavior ASP MVC
本文介绍了如何为基于单击行为的ASP MVC设置文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当用户在视图中单击链接文本click
时,如何使用字符串"N/A
"设置TextBoxtFor
值
How can I set TextBoxtFor
value with string "N/A
", when a user click the link text click
in the view
下面是我的代码:
<div class="form-group">
<div class="col-md-6">
@Html.TextBoxFor(m => m.ReferralId, new { @class = "form-control", id="CheckReferralId", placeholder = "Referral ID (Inviter)", required = "required", tabindex = 0 })
@Html.ValidationMessageFor(m => m.ReferralId, null, new { @class = "text-danger" })
<small>If you do not have Referral ID, <a href="#">click</a></small>
</div>
</div>
谢谢!
推荐答案
您可以将一个类添加到引用ID锚点,例如class="no-referral-link"
,然后下面的jQuery应该可以解决问题
You can add a class to the referral id anchors, say class="no-referral-link"
and then the following jQuery should do the trick
HTML
<small>If you do not have Referral ID, <a href="#" class="no-referral-link">click</a></small>
jQuery
$('.no-referral-link').click(function(e) {
$('#CheckReferralId').val('N/A');
});
这篇关于如何为基于单击行为的ASP MVC设置文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文