且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用c#.net将字符串转换成html文本框

更新时间:2022-12-20 16:39:05

您可以通过Text属性直接将文本分配给您的文本框,将值设置为来自服务器端的HTML控件,可以使用RegisterClientScriptBlock编写脚本来分配值并从后面的代码中注册它.
You can directly assign text to your textbox by Text property, To set values to HTML control from server side, you can write script to assign value and register it from code behind, by using RegisterClientScriptBlock.


如果您使用的是asp.net
在您的代码文件中使用:
if you are using asp.net
in your code file use:
textField.Value = "Text";


而"textField"是您的文本框.
另一个解决方案是如果要在客户端使用javascript.


and "textField" is your textbox.
Another solution is to use javascript if you want to do this client side.


您好,如果您使用JS进行打印,则在打印命令之前,请设置文本框值.

您可以将以下代码用于设置值

Hi, if you are using JS for printing then before print command, set text box value.

You can use below code for set value

document.getElementById('<%=textbox1.ClientID%>').value = "ABC";