开发者

asp.net to change label's text with textbox.text [closed]

开发者 https://www.devze.com 2023-02-09 07:59 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help 开发者
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help 开发者_如何学Cclarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

if i have a label with text initially and i would like to update the label's text with a textbox.text.. how should i do that?


On server side,

Label1.Text = Textbox1.Text;

On client side (via JS),

document.getElementById('[Label1 Client Id]').innerHTML = document.getElementById('[Textbox1 Client Id]').value;

BTW, even if you change the label client side, it would be restored to original value on post-back so you should change it on server side as well as.


If you want to change the text on textbox text change event then you have to do that using javascript.

But if you want to do that on button click event then please use the button and on the button click event use this code in code behind.

Label1.Text = Textbox1.Text;
0

精彩评论

暂无评论...
验证码 换一张
取 消