![]() |
Button that just calls a sub (and does NOT submit the form)
Hi,
I want a button that just calls a subroutine (rather than submitting a form). So, I have done this: <asp:Button id="btNewNetworkProvider" text="New" commandname="newprovider" onclick="newprovider" runat="server"/> and: Sub newprovider(sender As Object, e As EventArgs) ... End Sub However when I press the button it just submits the form. There is already another button that does the submit and I have tried setting: <form id="Form1" defaultbutton="btSubmit" .. but this has changed nothing. Regards, Paul |
Re: Button that just calls a sub (and does NOT submit the form)
The Button control is rendered as <input type="submit"> by default, so
clicking the button will make a post, I would suggest you to to either use Ajax to make the post "invisible" or you can add a Button and set the OnClientClick to something like "window.open('page.aspx'); return false;", this will popup a new window where page.aspx would call your sub and close itself. have a look at http://msdn.microsoft.com/library/de...ods/open_0.asp if you want to make change the properties of the popup window. Remember that some popup blockers may stops this popup from opening. Bruno <paul.richards@shropshirefire.gov.uk> wrote in message news:1174303126.285269.307140@l77g2000hsb.googlegr oups.com... > Hi, > > I want a button that just calls a subroutine (rather than submitting a > form). So, I have done this: > > <asp:Button id="btNewNetworkProvider" text="New" > commandname="newprovider" onclick="newprovider" runat="server"/> > > and: > > Sub newprovider(sender As Object, e As EventArgs) > ... > End Sub > > However when I press the button it just submits the form. There is > already another button that does the submit and I have tried setting: > > <form id="Form1" defaultbutton="btSubmit" .. > > but this has changed nothing. > > Regards, > > Paul > |
Re: Button that just calls a sub (and does NOT submit the form)
paul.richards@shropshirefire.gov.uk wrote: > Hi, > > I want a button that just calls a subroutine (rather than submitting a > form). So, I have done this: > > <asp:Button id="btNewNetworkProvider" text="New" > commandname="newprovider" onclick="newprovider" runat="server"/> > > and: > > Sub newprovider(sender As Object, e As EventArgs) > ... > End Sub > You can't execute a subrutine on the server-side without the form submission if you use the usual ASP.Net controls. If you familiar with javascript you can use XmlHttpRequest. If not - here ajax.asp.net you can find some convenient controls that utilize it. To be honest: this contols also submit a form but they do not cause page reloading and the submission is not visible for the user of your site. |
| All times are GMT. The time now is 01:32 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.