check that you're getting the reference to your div correctly first.
On 14 Nov, 15:20, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> I'm trying to trigger a postback from a regular html control
> dynamically created in javascript. Consider the following :
>
> <body onload="load()">
> <form id="form1" runat="server">
>
> <asp:LinkButton ID="delete" OnClick="OnDelete"
> runat="server">Delete</asp:LinkButton>
>
> <div id="cont"></div>
> </form>
> </body>
>
> When the LinkButton is clicked this triggers a postback and calls
> the .server side method OnDelete . In the background the LinkButton
> looks actually like this :
>
> <a id="delete" href="javascript:__doPostBack('delete','')">Delete</
> a>
>
> and the __doPostBack method is:
>
> function __doPostBack(eventTarget, eventArgument) {
> if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
> theForm.__EVENTTARGET.value = eventTarget;
> theForm.__EVENTARGUMENT.value = eventArgument;
> theForm.submit();
> }
>
> }
>
> Now, on the body load event I'm just creating a new A markup which I
> append to the div 'cont' :
>
> function load() {
> $("#cont").append("<a id='newLink' href='javascript:__doPostBack
> ('newLink', '');'>NewLink</a>");
> }
>
> If I click on the new link, there's a javascript error (but no error
> message in particular) and the postback is not triggered.
>
> What am I doing wrong ?
>
> Thanks