views:

161

answers:

3

I use yui datatable in my asp.net application... I have a link button in one of my columns and it works fine but doesn't do a postback of a hidden button...

 myDataTable.subscribe("linkClickEvent", function(oArgs) {
            javascript: __doPostBack('ctl00_ContentPlaceHolder1_Button1', '');
            YAHOO.util.Event.stopEvent(oArgs.event);
        });

and in my page

<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button"
   style="display:none;" />

 protected void Button1_Click(object sender, EventArgs e)
 {
    DownloadFile(Hfhref.Value, true);
 }

I used break point but it doesn't seem to get the __dopostback.. Any suggestion...

A: 

In your markup, make sure to properly case the OnClick handler.

onclick="Button1_Click"

should be

OnClick="Button1_Click"

The way you have written it, onclick will be interpreted as an attribute of the control and onclick="Button1_Click" will be rendered to the browser, instead of being handled on the server side.

Chris Shouts
@paper that didnt work for me... But look at my answer it worked...
Pandiya Chendur
A: 

I just did this and it worked,

document.getElementById("ctl00_ContentPlaceHolder1_Button1").click();

just call click() my button it worked...

I want to know whether it works in all browsers...

Pandiya Chendur
+1  A: 

add unique id on __doPostBackMethod from Button.

TriLLi
How did I not see that? The first parameter of __doPostBack should be the Control's UniqueId, not the ClientId. Good catch.
Chris Shouts