通过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[^]