0

I'm creating SQL query editor.My idea is there is a textarea in which user insert query like select * from tbl and then I get text from textarea and then put in sqlcommand and execute query and show result in gridview.But Problem is how can I change keyword color like when user enter INSERT or SELECT command then automatically it change color blue like in SQL query editor and all other keywords like SELECT, INSERT, UPDATE, DELETE and so on.How can I change color runtime in textarea.

Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252
Hameed
  • 51
  • 4
  • 16

2 Answers2

0

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
Vicky
  • 2,027
  • 1
  • 19
  • 31
-1

You said it's a c#/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

cs95
  • 379,657
  • 97
  • 704
  • 746
Proxy
  • 1,118
  • 2
  • 10
  • 27
  • I try this link solution `http://stackoverflow.com/questions/37139076/change-color-of-specific-words-in-textarea' but When i execute its running but problem is color not changing – Hameed Jun 09 '16 at 11:55
  • It's not changing because you are matching value form the text area against those if statements. If you write only one word, let's say SELECT it will color it but after that everything else you type even space wont match anything in the if statements because the value won't match. You need some kind of plugin or nest html tags inside each other to accomplish what you need – Proxy Jun 09 '16 at 11:59
  • I just noticed that the answer for that question is what you need more or less. You can copy it and adjust as you see fit – Proxy Jun 09 '16 at 12:12
  • Can u help me here is my e-Mail `[email protected] ` – Hameed Jun 09 '16 at 12:14
  • Help with what? You just need to copy&pate that code into your own, i just tested it and it works fine. Can you elaborate where the problem is? Here you can see that it is working http://jsbin.com/xikikamufa/3/edit?html,css,js,output – Proxy Jun 09 '16 at 12:15
  • I copy paste but not working.I'm using first solution.It's running but color not changing – Hameed Jun 09 '16 at 12:16
  • did you click on the link i gave you? you can see it's working – Proxy Jun 09 '16 at 12:17
  • here working fine i know but not working in visual studio 2010. – Hameed Jun 09 '16 at 12:23
  • I can see only the 2 picture. Have you included the css file as well in your application? – Proxy Jun 09 '16 at 12:34
  • Yes i have css code in aspx file.Here you can see http://i68.tinypic.com/140cc1t.png – Hameed Jun 09 '16 at 12:45
  • what do you get why you run the app? can you send a picture of that – Proxy Jun 09 '16 at 13:00
  • I'm getting div with background color black when i write `SELECT` and press space then color not changing of `SELECT` – Hameed Jun 09 '16 at 13:07
  • Does it color the syntax when you only type select? Maybe the jquery is not loading check if there are any error in the chrome console (or some other browser you are using) – Proxy Jun 09 '16 at 13:14
  • No it's not color the syntax when i write `SELECT` and how can i check chrome console? – Hameed Jun 09 '16 at 13:26
  • ctrl+shift+i or right click with mouse and inspect element – Proxy Jun 10 '16 at 05:46