Click here to Skip to main content
15,905,875 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
else if (answer is TextAnswer)
                            {
                                this.Sourcecode.AppendLine("\t\t\t\t<textarea id='" + id + "' name='" + id + "' value='' style='position: absolute; "
                                                         + "top: " + top + "px; left: " + left + "px; height: " + height + "px; width: " + width + "px; "
                                                         + "visibility:hidden; z-index: 2; resize: none;'></textarea>");

this line of code creates textbox control on my web form but the Problem is there is no focus set on it and i want to set focus How to do this???
This line of code works perfectly fine i mean when i click on my web form it crates a control , Now when i click on it, it creates a control to write something then i have to click on it again , so i just want that when i click focus should be there.How to do it??????
Posted
Updated 10-Mar-15 0:34am
v3

1 solution

Can use simple JavaScript code like this

JavaScript
document.getElementById("yourTextBoxId").focus();
 
Share this answer
 
Comments
Member 11000455 10-Mar-15 6:37am    
I know but i have to develop with above Code , I tried this code after first line not seems working
this.Sourcecode.AppendLine("<script>\t\t\t\tdocument.getElementById (" + id + ").focus();</script>");

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900