Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   c# how to execute code and then submit a form (http://www.velocityreviews.com/forums/t620981-c-how-to-execute-code-and-then-submit-a-form.html)

j1dopeman@gmail.com 06-18-2008 03:20 PM

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

David Wier 06-18-2008 04:44 PM

Re: c# how to execute code and then submit a form
 
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


<j1dopeman@gmail.com> wrote in message
news:6d723339-e689-4158-8418-2e69de907f68@8g2000hse.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




j1dopeman@gmail.com 06-18-2008 05:15 PM

Re: c# how to execute code and then submit a form
 
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.com> wrote:
> 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.com> wrote in message
>
> news:6d723339-e689-4158-8418-2e69de907f68@8g2000hse.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



David Wier 06-18-2008 05:45 PM

Re: c# how to execute code and then submit a form
 
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


<j1dopeman@gmail.com> wrote in message
news:b31caf30-3bfe-4908-883e-9b6819643c8f@m44g2000hsc.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.com> wrote:
> 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.com> wrote in message
>
> news:6d723339-e689-4158-8418-2e69de907f68@8g2000hse.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




j1dopeman@gmail.com 06-18-2008 06:09 PM

Re: c# how to execute code and then submit a form
 
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.com> wrote:
> 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.com> wrote in message
>
> news:b31caf30-3bfe-4908-883e-9b6819643c8f@m44g2000hsc.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.com> wrote:
>
> > 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.com> wrote in message

>
> >news:6d723339-e689-4158-8418-2e69de907f68@8g2000hse.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


j1dopeman@gmail.com 06-18-2008 06:48 PM

Re: c# how to execute code and then submit a form
 
Nope, if I use a semicolon it tells me that mahButton_click is
undefined. Such a simple task, and what a pain in the ass it is to
find out how to do it.

On Jun 18, 2:09*pm, j1dope...@gmail.com wrote:
> 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.com> wrote:
>
> > 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.com> wrote in message

>
> >news:b31caf30-3bfe-4908-883e-9b6819643c8f@m44g2000hsc.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.com> wrote:

>
> > > 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-Oneclick PDF, convert
> > > .doc/.rtf/.txt to HTML with no
> > > bloated markup

>
> > > <j1dope...@gmail.com> wrote in message

>
> > >news:6d723339-e689-4158-8418-2e69de907f68@8g2000hse.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


j1dopeman@gmail.com 06-19-2008 03:28 PM

Re: c# how to execute code and then submit a form
 
I ended up using this:

http://forums.asp.net/p/1080161/1596598.aspx

to register a script that will submit the form after the postback for
the button.

On Jun 18, 2:48*pm, j1dope...@gmail.com wrote:
> Nope, if I use a semicolon it tells me that mahButton_click is
> undefined. *Such a simple task, and what a pain in the ass it is to
> find out how to do it.
>
> On Jun 18, 2:09*pm, j1dope...@gmail.com wrote:
>
> > 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.com> wrote:

>
> > > 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-Oneclick PDF, convert .doc/.rtf/.txt to HTML with no
> > > bloated markup

>
> > > <j1dope...@gmail.com> wrote in message

>
> > >news:b31caf30-3bfe-4908-883e-9b6819643c8f@m44g2000hsc.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.com> wrote:

>
> > > > 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-OneclickPDF, convert
> > > > .doc/.rtf/.txt to HTML with no
> > > > bloated markup

>
> > > > <j1dope...@gmail.com> wrote in message

>
> > > >news:6d723339-e689-4158-8418-2e69de907f68@8g2000hse.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



All times are GMT. The time now is 11:29 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.