我正在创建SQL查询编辑器。我的想法是有一个textarea
,用户可以在其中插入类似select * from tbl
查询,然后从textarea
获取文本,然后放入sqlcommand
并执行查询并在gridview中显示结果。我可以像在用户输入INSERT
或SELECT
命令时那样更改关键字颜色,然后像在SQL查询编辑器中以及在所有其他关键字(如SELECT
, INSERT
, UPDATE
, DELETE
等)一样自动将颜色更改为blue
。如何在textarea中更改颜色运行时。
You can try it using css . Note-Change color to any choice(this one is red):
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
input, select, textarea{
color: #ff0000;
}
textarea:focus, input:focus {
color: #ff0000;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<textarea id="textarea" cols="20" name="S1" rows="2"></textarea></p>
</body>
</html>
Update
I thought to try but you can get this is already done :
http://stackoverflow.com/questions/37139076/change-color-of-specific-words-in-textarea
You said it's ac#/javascript problem so i assume it's a web site on the client side. If so i don't think you are able to change color of each individual word in an textarea but you should use some 3 party plugins to get an "improved" textarea or use other tags to achieve this functionality
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.