I use yui datatable in my asp 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...
I use yui datatable in my asp 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...
- @Panidiya Why you have type on front javascript: ? – Aristos Commented Apr 16, 2010 at 12:21
- @Aristos releasing that too didnt work.. – ACP Commented Apr 16, 2010 at 12:23
4 Answers
Reset to default 3add unique id on __doPostBackMethod from Button.
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...
If you're using ASP.Net 4.0 framework, add ClientIDMode="Static"
to your control declaration and you can call __doPostBack('Button1','');
directly.
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button"
style="display:none;" ClientIDMode="Static" />
The ClientIDMode attribute is new to 4.0 and allows you the option of having a known unique id for controls. Calling postback for the control will run whatever postback method is defined in the control's OnClick attribute.
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.