Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Button that just calls a sub (and does NOT submit the form)

Reply
Thread Tools

Button that just calls a sub (and does NOT submit the form)

 
 
paul.richards@shropshirefire.gov.uk
Guest
Posts: n/a
 
      03-19-2007
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

 
Reply With Quote
 
 
 
 
Bruno Piovan
Guest
Posts: n/a
 
      03-19-2007
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

<> wrote in message
news: 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
>


 
Reply With Quote
 
 
 
 
marss
Guest
Posts: n/a
 
      03-20-2007

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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
Death To Sub-Sub-Sub-Directories! Lawrence D'Oliveiro Java 92 05-20-2011 06:50 AM
STRUTS- <html:submit> does not submit on pressing Enter key Megha Vishwanath Java 2 10-02-2009 12:52 PM
Recognising Sub-Items and sub-sub items using xslt Ben XML 2 09-19-2007 09:35 AM
Form submit - hitting enter does not trigger Submit button ASP General 2 10-25-2004 03:37 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57