0

I have a asp.net label inside a

 <td>
 <asp:Label ID="errorMesaage" runat="server">  
   </td>

I want to create an asp.net label dynamically and append it to this td using JAVASCRIPT. Then after appending this td would have another error message with a different id. I also need a script that would also remove the item from the

Any help is appreciated.

2 Answers 2

3

No, you can't because the asp.net label is a server control so does not make sense in client code, ie on code rendered on client. If you add it with javascript in your page it will not work at all.

You can add asp.net label dinamically in your server side code with something like

var lbl = new Label();
Page.Controls.Add(lbl);
Sign up to request clarification or add additional context in comments.

1 Comment

so what is the wortk around..can you tell me how to add html control and then remove it from the div based on a unique id that i would pass....i want to make it look like a map...which has some elements based on a key...actually i have different errors for each row in a grid and want to display and remove the errors based on the id that is assigned to each row
0

I found a solution...what I did was that I cloned my current asp.net label using the Javascript clone method.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.