Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am appending asp textbox to a table there but it is not appending.
It is throwing error please any one help me..........
This way I have done please find the line of code.
JavaScript
$("#tbDetails").append("<table><tbody><tr><td>" + data.d[i].Field_text + "</td><td>" + ':' + "</td><td><asp:TextBox ID='txtDetails" + i + " runat='server' /></td></tr></tbody></table>");

It is throwing error The server tag is not well formed.
Posted
v2

Are you missing a single quote after txtDetails?

<asp:textbox id='txtDetails"+i+"'.....
 
Share this answer
 
v3
Comments
BalaMahesh 26-Nov-12 7:29am    
$("#tbDetails1").append("<tr><td>" + data.d[i].Field_text + "</td><td>" + ':' + "</td><td><asp:TextBox ID='txtDetails1" + i + "' runat='server' /></td></tr>");
This way also i tried but in designer.cs file its throwing Error
Like ;Excepetced
Is it possible Asp server control(textbox) to append a table?
Jyotish Pillai 27-Nov-12 5:20am    
Better you tell us the requirement. We can find another way :)
Try using the following and let me know ...

$("#tbDetails").append("<table><tbody><tr><td>" + data.d[i].Field_text + "</td><td>:</td><td><asp:TextBox ID='txtDetails" + i + "' runat='server' /></td></tr></tbody></table>");

NOTE: Please don't add any pre tags or edit this code.
Because it adds extra quotes and makes the code different.
 
Share this answer
 
v2
Comments
BalaMahesh 26-Nov-12 7:24am    
i changed as per my requirement only but still its throwing same error and Designer.cs file also throwing build errors Expected ;
like that
Ok I will work this out and give you an update about it. Don't worry. :)
If you want textbox's value in server side then you can use it like this :

ASP.NET
<div id="divBox" runat="server">
</div>

Now in the script tag append the text box as input element.
JavaScript
$("#divBox").append("<input type='text' id='txtDetails'/>");

on the server side get the textbox by this way:
TextBox txt = (TextBox)divBox.FindControl("txtDetails");


Thanks. :)
 
Share this answer
 
Comments
BalaMahesh 26-Nov-12 7:22am    
$("#tbDetails").append("<tr><td>" + data.d[i].Field_text + "</td><td>" + ':' + "</td><td><input id='txtDetails" + i + "' type='text' /></td></tr>");
above way i done that.
HTML textbox its working fine but i want that text box value in server side.thats why i am changing again that HTML textbox to asp.net textbox
Please give me any alter native solution
jQuery works with the HTML DOM. So, you can not create any server side control using jQuery. You can only create html controls using jQuery.

If you want the value of the txtDetails,You can make javascript function to get value of that txtbox and then call that javascript function in your code-behind.


Hope that helps.
 
Share this answer
 

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