2

I want to add some text and an asp: button inside a Div using jQuery.

Code:

Hi,  <p> Are you sure you want to go ahead</p><p>Please ignore this warning if this is not the first time you are logging in</p>
<asp:button ID="btnProceed" runat="server" Text="Proceed"></asp:button>

Implementation:

jQ('#proceedDiv').append("<div> Hi,  <p> Are you sure you want to go ahead</p><p>Please ignore this warning if this is not the first time you are logging in</p> <asp:button ID="btnProceed" runat="server" Text="Proceed"></asp:button></div>");

but i am getting an error saying expected '('

That error is where button code starts. With alone text(and not button control) the code works fine. Can someone help me to fix it ?

7
  • Try to escape double apostrophe inside append-> \" Commented Nov 13, 2012 at 13:52
  • do you mean like this: <asp:Button ID=\"lnkGoback1\" runat=\"server\" ? it doesnot work. Any other way it should hv been done ? Commented Nov 13, 2012 at 13:58
  • Try switching them to single quotes instead: <asp:button ID='btnProceed' runat='server' Text='Proceed'> Commented Nov 13, 2012 at 14:00
  • 4
    You seem to be confusing server-side and client-side technologies. <asp:button> is a server-side component that renders to HTML markup in the page. jQuery allows you to modify that markup. Adding an <asp:button> element from the client side won't achieve anything, you should add the actual markup generated by the component instead. Commented Nov 13, 2012 at 14:06
  • Then how can I add a button using jQuery ? Commented Nov 13, 2012 at 14:43

1 Answer 1

0

You'll need to escape your quotes...

<asp:button ID="btnProceed" runat="server" Text="Proceed">

needs to become

<asp:button ID=\"btnProceed\" runat=\"server\" Text=\"Proceed\">

Also note that

<button onclick="doSomething()">Click Me</button>
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.