通过javascript访问文本框的值 [英] Accessing textbox's value by javascript

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

问题描述

大家好,

如何在文本框内获取价值.
就像我们在C#txtABC.Text中执行此操作.在javascript中执行什么操作?

如果我使用javascript客户端事件填充了标签,如何在服务器端访问其值?

它使用lblABC.Text
给出null
请帮忙...

谢谢
Amit

Hey everyone,

How to get value inside a textBox.
Like we do this in C# txtABC.Text.whats in javascript?

And if I''ve filled my label using javascript client side event,how will I access its value on server side?

It''s giving null using lblABC.Text

please help...

Thanks
Amit

推荐答案

可以使用
document.getelementbyid("TextBox1").Value;

:-O


您错过了引号和格式.

:-O


You missed the quotes and formatting.


如何在文本框内获取值.
就像我们在C#txtABC.Text中执行此操作一样.在JavaScript中使用什么?


How to get value inside a textBox.
Like we do this in C# txtABC.Text.whats in javascript?


var textboxValue = document.getElementById('TextBox1').value;




如果我使用javascript客户端事件填充了标签,我将如何在服务器端访问其值?

好吧,标签的值不会保留.因此,一种解决方法是使用隐藏字段.方法如下:

在aspx页面中:




And if i''ve filled my label using javascript client side event,how will i access its value on server side?

Well, the value of a label is not preserved. So a workaround would be to use a hidden field. Here''s how:

In the aspx page:

<asp:HiddenField ID="Amount" runat="server" />



在javascript中添加此行:



Add this line in javascript:

var amt = document.getElementById("Amount");
amt.value = parseInt(txtQuantityE.get_value()) * parseInt(lblRate.innerHTML);
//you may remove the line which assigns this value to label



并在后面的代码中:



And in the code behind:

lblAmount.Text = Amount.Value;



希望现在已经清楚了. :)



Hope this is clear now. :)


您最好从
开始 JavaScript教程 [ ^ ]
you better to start from
JavaScript Tutorial[^]


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

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