Javascript,获取文本框值问题 [英] Javascript, getting textbox value issue

查看:82
本文介绍了Javascript,获取文本框值问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我是asp.net的新手,面临一个奇怪的问题。我在gridView里面有textBox。



我想用JavaScript获取textBox值。我已经通过互联网上的解决方案并尝试下线。



var value = document.getElementById(<%= txtNewQuizID.ClientID%>) .value;



现在离开获取值,在这一行之后,页面本身没有打开。它显示在下面的消息。



呃哦,出了点问题!错误代码:500



我试图找出这行中的错误,所以我评论了该行,但仍然是同样的问题。然后在注释行中,我删除了<%和%>页面打开正确。所以问题是由于<%和%>。请告诉解决方案如何获取textBox的值。并且在我尝试过的上述行中有什么错误。

Hi Everyone,

I am new in asp.net and facing a strange issue. I have textBox inside gridView.

I want to get the textBox value using JavaScript. I have gone through the solution available in internet and tried below line.

var value = document.getElementById("<% = txtNewQuizID.ClientID %>").value;

For now leave about getting the value, after this line, the page itself is not opening. its showing below message.

Uh-oh, something went wrong! Error Code: 500

I tried to find out whats wrong in this line, so I commented the line but still same issue. Then in commented line, i have removed "<%" and "%>" then page opens properly. So the issue is because of the <% and %>. Please tell solution how to get value of textBox. and whats wrong in above line which i tried.

推荐答案

请参阅我对该问题的评论:到目前为止,您没有提供足够的信息。你需要显示那个元素,做得最少。



同时,请仔细阅读:

https://msdn.microsoft.com/en-us/ library / system.web.ui.control.clientid%28v = vs.110%29.aspx [ ^ ],

https://msdn.microsoft.com/en-us/library/system .web.ui.clientidmode(v = vs.110).aspx [ ^ ]。



但此时此刻,我'我不确定您是否了解在这种情况下服务器端和客户端站点上发生的情况。确保你理解它。



-SA
Please see my comment to the question: so far, you did not provide enough information. You need to show that element, to do the least.

In the meanwhile, read this thoroughly:
https://msdn.microsoft.com/en-us/library/system.web.ui.control.clientid%28v=vs.110%29.aspx[^],
https://msdn.microsoft.com/en-us/library/system.web.ui.clientidmode(v=vs.110).aspx[^].

But at this moment, I'm not sure you understand what happens on server side and on client site in such cases. Make sure you understand it.

—SA


这篇关于Javascript,获取文本框值问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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