CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2002
    Location
    Hyderabad,India.
    Posts
    27

    How To Submit Web Form

    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

    [email protected]

  2. #2
    Join Date
    Apr 2000
    Location
    Dallas, TX
    Posts
    173

    Lightbulb

    In your event handler for the submit button:

    Code:
    Response.Redirect("NextPage.aspx")

  3. #3
    Join Date
    May 2002
    Location
    Hyderabad,India.
    Posts
    27

    Response.Redirect won't works

    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

    [email protected]

  4. #4
    Join Date
    Apr 2000
    Location
    Dallas, TX
    Posts
    173
    One solution (this is easier if you are using VS.NET to do your development):

    In your sending page class, create public properties:
    Code:
    Public ReadOnly Property OneOfMyControls() As Object
        Get
            Return MyControl
        End Get
    End Property
    In your sending page class, modify your submit button event handler:
    Code:
    Server.Transfer("MySecondPage.aspx")
    In your receiving page class, modify your Page_Load event hander:
    Code:
    ' 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
    Preston Park
    CTT+, MCT, MCSD
    http://www.prestonpark.com/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured