Click here to Skip to main content
13,050,764 members (85,316 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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.
$("#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 25-Nov-12 21:52pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Are you missing a single quote after txtDetails?

<asp:textbox id='txtDetails"+i+"'.....
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 :)
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

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.
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
Tadit Dash 26-Nov-12 9:18am
Ok I will work this out and give you an update about it. Don't worry. :)
Rate this: bad
Please Sign up or sign in to vote.

Solution 4

If you want textbox's value in server side then you can use it like this :

<div id="divBox" runat="server">

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

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

Thanks. :)
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 textbox
Please give me any alter native solution
Rate this: bad
Please Sign up or sign in to vote.

Solution 5

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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 26 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100