473,396 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

c# how to execute code and then submit a form

Hi,

I'd like to use a button to save and then submit a form. I can set
the onlick of the button to mahButton_click or submit, but I can't
figure out how to do both.

It looks like c# can't call a form's submit. I've found how to post
programatically, but I need to use the form's target attribute so that
the response goes into another frame, and I can't figure out how to do
that programatically.

I looking into using javascript to call the c# method and then submit,
but I keep finding that javascript can't call c# methods.

The timing isn't important, I just need to find a way for the button
to execute my method and also submit the form. The only way I can
think of is to use another hidden button that calls my method, and
have the visible button call a javascript method that will click the
hidden button and also submit, but this doesn't seem like a very good
solution. Also, I don't want to write to the page, so using
response.write in mahButton_click to write out a javascript submit is
out.

Any help is very much appreciated.

Thanks,
John
Jun 27 '08 #1
4 5485
With one event handler, and using the built in Button control, with ASP.Net,
you can do any number of things easily.
Just call the save and then do whatever you need it to do after that.

Are we talking about an HTML form, or an ASP.Net form?

David Wier
http://aspnet101.com
http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
bloated markup
<j1*******@gmail.comwrote in message
news:6d**********************************@8g2000hs e.googlegroups.com...
Hi,

I'd like to use a button to save and then submit a form. I can set
the onlick of the button to mahButton_click or submit, but I can't
figure out how to do both.

It looks like c# can't call a form's submit. I've found how to post
programatically, but I need to use the form's target attribute so that
the response goes into another frame, and I can't figure out how to do
that programatically.

I looking into using javascript to call the c# method and then submit,
but I keep finding that javascript can't call c# methods.

The timing isn't important, I just need to find a way for the button
to execute my method and also submit the form. The only way I can
think of is to use another hidden button that calls my method, and
have the visible button call a javascript method that will click the
hidden button and also submit, but this doesn't seem like a very good
solution. Also, I don't want to write to the page, so using
response.write in mahButton_click to write out a javascript submit is
out.

Any help is very much appreciated.

Thanks,
John

Jun 27 '08 #2
I need to submit the form after that, how can I do that? I need to
submit it through the page so that the target attribute is set, or if
I do it programmatically I need to make sure the response goes to a
different frame. I'm using an asp.net form.

On Jun 18, 12:44*pm, "David Wier" <d...@dw.comwrote:
With one event handler, and using the built in Button control, with ASP.Net,
you can do any number of things easily.
Just call the save and then do whatever you need it to do after that.

Are we talking about an HTML form, or an ASP.Net form?

David Wierhttp://aspnet101.comhttp://iWritePro.com- One click PDF, convert .doc/.rtf/.txt to HTML with no
bloated markup

<j1dope...@gmail.comwrote in message

news:6d**********************************@8g2000hs e.googlegroups.com...
Hi,
I'd like to use a button to save and then submit a form. *I can set
the onlick of the button to mahButton_click or submit, but I can't
figure out how to do both.
It looks like c# can't call a form's submit. *I've found how to post
programatically, but I need to use the form's target attribute so that
the response goes into another frame, and I can't figure out how to do
that programatically.
I looking into using javascript to call the c# method and then submit,
but I keep finding that javascript can't call c# methods.
The timing isn't important, I just need to find a way for the button
to execute my method and also submit the form. *The only way I can
think of is to use another hidden button that calls my method, and
have the visible button call a javascript method that will click the
hidden button and also submit, but this doesn't seem like a very good
solution. *Also, I don't want to write to the page, so using
response.write in mahButton_click to write out a javascript submit is
out.
Any help is very much appreciated.
Thanks,
John
Jun 27 '08 #3
Really, with the ASP.net paradigm, there is no 'submission' of a form, like
in PHP or Classic ASP days. You should get a 'handle' on the new way ASP.Net
programming actually works
This is all Object oriented/Event Driven code.

Therefore, like I said earlier, with one ASP.Net button (an object), you can
do however many things you'd like, all in one event (the button click event)
You can insert/update/delete/search data, and then anything else - like
maybe redirecting to another page.

What exactly do you mean by "I need to submit the form after that.."?

David Wier
http://aspnet101.com
http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
bloated markup
<j1*******@gmail.comwrote in message
news:b3**********************************@m44g2000 hsc.googlegroups.com...
I need to submit the form after that, how can I do that? I need to
submit it through the page so that the target attribute is set, or if
I do it programmatically I need to make sure the response goes to a
different frame. I'm using an asp.net form.

On Jun 18, 12:44 pm, "David Wier" <d...@dw.comwrote:
With one event handler, and using the built in Button control, with
ASP.Net,
you can do any number of things easily.
Just call the save and then do whatever you need it to do after that.

Are we talking about an HTML form, or an ASP.Net form?

David Wierhttp://aspnet101.comhttp://iWritePro.com- One click PDF, convert
.doc/.rtf/.txt to HTML with no
bloated markup

<j1dope...@gmail.comwrote in message

news:6d**********************************@8g2000hs e.googlegroups.com...
Hi,
I'd like to use a button to save and then submit a form. I can set
the onlick of the button to mahButton_click or submit, but I can't
figure out how to do both.
It looks like c# can't call a form's submit. I've found how to post
programatically, but I need to use the form's target attribute so that
the response goes into another frame, and I can't figure out how to do
that programatically.
I looking into using javascript to call the c# method and then submit,
but I keep finding that javascript can't call c# methods.
The timing isn't important, I just need to find a way for the button
to execute my method and also submit the form. The only way I can
think of is to use another hidden button that calls my method, and
have the visible button call a javascript method that will click the
hidden button and also submit, but this doesn't seem like a very good
solution. Also, I don't want to write to the page, so using
response.write in mahButton_click to write out a javascript submit is
out.
Any help is very much appreciated.
Thanks,
John

Jun 27 '08 #4
I need to submit to another page - to post to a different page. The
action is happening at that other page, and the response is going into
another frame. That's all I need to do. I'm not rewriting anything,
I have a few inputs on the form, and I need to submit the form.
Here's my form:

<form runat="server" name="mahForm" id="mahForm" method="post"
action="someOtherPlace/someOtherPage.asp" target="someOtherFrame">

here's my button:

<asp:button runat="server" id="mahButton" Text="Hit It"
OnClick="submit"or
<asp:button runat="server" id="mahButton" Text="Hit It"
OnClick="mahButton_click">
</form>

I want to change that or into and. Looks like all I need is a
semicolon, I'm gonna go ahead and try that out.

On Jun 18, 1:45*pm, "David Wier" <d...@dw.comwrote:
Really, with the ASP.net paradigm, there is no 'submission' of a form, like
in PHP or Classic ASP days. You should get a 'handle' on the new way ASP.Net
programming actually works
This is all Object oriented/Event Driven code.

Therefore, like I said earlier, with one ASP.Net button (an object), you can
do however many things you'd like, all in one event (the button click event)
You can insert/update/delete/search data, and then anything else - like
maybe redirecting to another page.

What exactly do you mean by "I need to submit the form after that.."?

David Wierhttp://aspnet101.comhttp://iWritePro.com- One click PDF, convert .doc/.rtf/.txt to HTML with no
bloated markup

<j1dope...@gmail.comwrote in message

news:b3**********************************@m44g2000 hsc.googlegroups.com...
I need to submit the form after that, how can I do that? *I need to
submit it through the page so that the target attribute is set, or if
I do it programmatically I need to make sure the response goes to a
different frame. *I'm using an asp.net form.

On Jun 18, 12:44 pm, "David Wier" <d...@dw.comwrote:
With one event handler, and using the built in Button control, with
ASP.Net,
you can do any number of things easily.
Just call the save and then do whatever you need it to do after that.
Are we talking about an HTML form, or an ASP.Net form?
David Wierhttp://aspnet101.comhttp://iWritePro.com-One click PDF, convert
.doc/.rtf/.txt to HTML with no
bloated markup
<j1dope...@gmail.comwrote in message
news:6d**********************************@8g2000hs e.googlegroups.com...
Hi,
I'd like to use a button to save and then submit a form. I can set
the onlick of the button to mahButton_click or submit, but I can't
figure out how to do both.
It looks like c# can't call a form's submit. I've found how to post
programatically, but I need to use the form's target attribute so that
the response goes into another frame, and I can't figure out how to do
that programatically.
I looking into using javascript to call the c# method and then submit,
but I keep finding that javascript can't call c# methods.
The timing isn't important, I just need to find a way for the button
to execute my method and also submit the form. The only way I can
think of is to use another hidden button that calls my method, and
have the visible button call a javascript method that will click the
hidden button and also submit, but this doesn't seem like a very good
solution. Also, I don't want to write to the page, so using
response.write in mahButton_click to write out a javascript submit is
out.
Any help is very much appreciated.
Thanks,
John
Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ice Man | last post by:
Hi all How Can I submit a form by clicking on an image instead of the submit button? Thanks
3
by: Matt | last post by:
When people say submit the form data, does it mean the form data are submitted to web browser using either HTTP GET or POST method, and then it will redirect to another page. For example, this...
2
by: Terence Parker | last post by:
How does one go about submitting a form with a link - but submitting it to a new window AND to a page different to that described within the action="" option of the <form> tag? Say, for example,...
6
by: CJM | last post by:
Can somebody clarify if/how/when a simple form is submitted when the <Enter> key is pressed? As I understood it, if you have a form with a single submit button, if enter is pressed, the form...
19
by: Bruce Duncan | last post by:
I know this isn't a php group but I was wondering if my problem is with my javascript in my php code. I'm debugging someone else's code and I can't figure out why this form won't submit. This...
1
by: Andy Kasotia | last post by:
I have an ASP UI with VB Dll as a COM object that access the DB2 Database. I have a "Calculate" button on the ASP Page which when clicked does form validation (javascript) and submits the form...
5
by: Navillus | last post by:
Hey gang, I have a login form that is empty by default, but can be filled with values from a previous form: <input type=text maxlength="40" size="40" name="user" value="`usr`"> <input...
4
by: MichaelK | last post by:
Hello. I have all data already collected on the current page? I want to open another window with the form, fill the fields and submit that form. So basically the question is how can I fill all...
4
LeoTD
by: LeoTD | last post by:
Dear all, I'm newbiew in Javascritp, i have a question about submit form automatically. Here is my code: <form id="frmTest" action="www.example.com" method="post"> <input type="hidden"...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.