Any way to launch a VB.NET button from Javascript?

I have a menu on my aspx page that looks beautiful. This is exactly what I need (found here ).

The problem that I have is this: I need to (somehow) launch the control button with javascript. I understand that in this example, the menu items are just href links, but I wonder how I could make a postback and fire the Button1_OnClick event.

Any ideas?

Thanks Jason

Note that Button1 is an ASP button with server side VB.NET code.

+3
source share
4 answers

The method of click()any element <a>simulates a click.

0
source

You will need something like

 __doPostBack(*Button1 clientId*,"OnClick") ;
+2
source

Button1 "ClientID". HTML-, document.getElementById("<%= Button1.ClientID %>"), , .

:

document.getElementById("<%= Button1.ClientID %>").click();

, .click() . JavaScript ( ):

// Where 'button' is the value of the document.getElementById() function:
if (button.dispatchEvent) {
    var e = document.createEvent("MouseEvents");
    e.initEvent("click", true, true);
    button.dispatchEvent(e);
}
else {
    button.click();
}
+1

<a />, LinkButtons. <a /> runat="server", .

0

All Articles