Click to See Complete Forum and Search --> : How To Submit Web Form


prasad_agv
May 30th, 2002, 07:42 AM
hai,

i have a problem in ASP.NET. If i am submiting web form page
to another page it's not navigating to that page, instead
it submitting to same page.

For eg.,

===PageOne.aspx===

<form runat="server" id="f1" action="NextPage.aspx">

<asp:Button id="b1" runat="server" Text="Click" />

</form>


If i click the button it should navigate to "NextPage.aspx" page,
but it submitting to same page ie., PageOne.aspx.

Looking for ur suggestions.

bye

prasad_agv@yahoo.com

pjpark
May 30th, 2002, 09:24 AM
In your event handler for the submit button:


Response.Redirect("NextPage.aspx")

prasad_agv
May 31st, 2002, 06:21 AM
Hai pjpark,

Thanks for reply.

For my problem i.e., How to submit web form. U
replied use 'Response.Redirect("NextPage.aspx")'.
But if we code in this way, the values which are
entered in first page(in textbox or textarea), that
values won't be submitted to "NextPage.aspx".
I want to capture entered values of first page,
in NextPage.aspx through 'Request("textbox1")'.
Ofcourse, by coding in ur way i.e., Response.Redirect
("NextPage.aspx"), before redirecting to NextPage.aspx,
we can create cookies and assign values which are entered
in textboxes and we can capture the values of cookies
in NextPage.aspx, but that's a cumbersome process.
We have to submit through action attribute of form
tag. Please try it.

looking for ur reply

thanks

prasad_agv@yahoo.coim

pjpark
May 31st, 2002, 10:35 AM
One solution (this is easier if you are using VS.NET to do your development):

In your sending page class, create public properties:
Public ReadOnly Property OneOfMyControls() As Object
Get
Return MyControl
End Get
End Property

In your sending page class, modify your submit button event handler:
Server.Transfer("MySecondPage.aspx")

In your receiving page class, modify your Page_Load event hander:
' MyFirstPage is the class name for code-behind of MyFirstPage.aspx
Dim objSender As MyFirstPage

objSender = CType(context.Handler, MyFirstPage)
Response.Write(objSender.OneOfMyControls.Text

Disclaimer: This example gives the general idea and is not meant to be bug free or even best practices. You may want to expose the values rather than the actual controls in your sending page class. You can also try looking at the controls collection of the sending page; however, I have had little success with this.
Good luck,

pjp