如何改变一个asp的值:从JavaScript文本 [英] How to change the value of an asp:textbox from javascript

查看:96
本文介绍了如何改变一个asp的值:从JavaScript文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个asp:文本框

I have an asp:textbox

<asp:textbox ID="NewName" runat="server" />

和当用户单击取消按钮,我想删除无论是在该文本框通过价值仅仅是。如果是类型文本输入框,我可以做到这一点在JavaScript:

and when a user clicks the "Cancel" button, I want to erase whatever is in that text box by making the value just be "". If it were a an input field of type text, I could just do this in javascript:

document.getElementById('NewName').value= "";

但我不能只是这样做,因为这是一个asp:文本框。

But I can't just do this because it is an asp:textbox.

推荐答案

当你的ASP:文本框呈现给用户界面,那么是的,这只是一个类型的文本输入字段。这可能是一个问题的唯一部分是ID,但在使用的ClientIDMode可以设置

When your asp:textbox is rendered to the UI, then yes, it is just an input field of type text. The only part that may be an issue is the ID, but that can be set using ClientIDMode:

<asp:textbox ID="NewName" runat="server" ClientIDMode="Static" />

渲染为:

<input type="text" id="NewName" />

和因此JavaScript的使用应该很好地工作。

and thus the JavaScript you use should work perfectly.

这篇关于如何改变一个asp的值:从JavaScript文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆