No Postback Just Open Another Page

Discussion in 'ASP .Net Web Controls' started by Art Cabot, Feb 7, 2005.

  1. Art Cabot

    Art Cabot Guest

    ASP.NET Newbie Question:
    I have buttons (<asp:button) on my page that I want to just open another
    page (including some arguments from the original page), just like would
    normally happen with the "action=" on a form. I can't seem to get it to stop
    posting back, the HTML source always shows "action=original page", regardless
    of what page I set the "action =" to.

    Am I missing something really obvious here?
    --
    Art Cabot
    Strickland Technical Services, Inc.
    Augusta, Georgia
     
    Art Cabot, Feb 7, 2005
    #1
    1. Advertising

  2. Hi Art,

    An ASP.NET page always posts back to itself, so that's the issue you're
    encountering. Setting the action page doesn't help.

    Try this to pass a value from one control to a second page:

    1. Create a new page called btntrsfr.aspx and drop a Button and Textbox on
    it.
    2. Use the following code for Button1's Click event:

    Private Sub Button1_Click _
    (ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
    Context.Items("txtValue") = TextBox1.Text
    Server.Transfer("targetpg.aspx")
    End Sub

    3. Create the target page called targetpg.aspx .
    4. Add a label control to the page.
    5. Use the following code for the page's Load event:

    Label1.Text = CType(Context.Items("txtValue"), String)

    You should be able to type something in the text of btntrsfr.aspx, click the
    button and see the text show up in the label of targetpg.aspx.

    Let us know if this helps?

    Ken
    Microsoft MVP [ASP.NET]
    Toronto

    "Art Cabot" <> wrote in message
    news:...
    > ASP.NET Newbie Question:
    > I have buttons (<asp:button) on my page that I want to just open another
    > page (including some arguments from the original page), just like would
    > normally happen with the "action=" on a form. I can't seem to get it to
    > stop
    > posting back, the HTML source always shows "action=original page",
    > regardless
    > of what page I set the "action =" to.
    >
    > Am I missing something really obvious here?
    > --
    > Art Cabot
    > Strickland Technical Services, Inc.
    > Augusta, Georgia
     
    Ken Cox [Microsoft MVP], Feb 7, 2005
    #2
    1. Advertising

  3. Hello Art,
    Please note that you can still use the HTML controls as <input
    type="button" onclick=""> and you can set the action of the form then
    submit to the new page.
    This is more like a workaround but it will achieve what you want.

    Regards
    Mohamed El Ashmawy
    MEA Developer Support Center
    ITWorx on behalf of Microsoft EMEA GTSC
     
    Mohamed El Ashmawy, Feb 8, 2005
    #3
  4. Art Cabot

    Art Cabot Guest

    Thanks, Ken. It works great!

    Art


    "Ken Cox [Microsoft MVP]" wrote:

    > Hi Art,
    >
    > An ASP.NET page always posts back to itself, so that's the issue you're
    > encountering. Setting the action page doesn't help.
    >
    > Try this to pass a value from one control to a second page:
    >
    > 1. Create a new page called btntrsfr.aspx and drop a Button and Textbox on
    > it.
    > 2. Use the following code for Button1's Click event:
    >
    > Private Sub Button1_Click _
    > (ByVal sender As System.Object, _
    > ByVal e As System.EventArgs) Handles Button1.Click
    > Context.Items("txtValue") = TextBox1.Text
    > Server.Transfer("targetpg.aspx")
    > End Sub
    >
    > 3. Create the target page called targetpg.aspx .
    > 4. Add a label control to the page.
    > 5. Use the following code for the page's Load event:
    >
    > Label1.Text = CType(Context.Items("txtValue"), String)
    >
    > You should be able to type something in the text of btntrsfr.aspx, click the
    > button and see the text show up in the label of targetpg.aspx.
    >
    > Let us know if this helps?
    >
    > Ken
    > Microsoft MVP [ASP.NET]
    > Toronto
    >
    > "Art Cabot" <> wrote in message
    > news:...
    > > ASP.NET Newbie Question:
    > > I have buttons (<asp:button) on my page that I want to just open another
    > > page (including some arguments from the original page), just like would
    > > normally happen with the "action=" on a form. I can't seem to get it to
    > > stop
    > > posting back, the HTML source always shows "action=original page",
    > > regardless
    > > of what page I set the "action =" to.
    > >
    > > Am I missing something really obvious here?
    > > --
    > > Art Cabot
    > > Strickland Technical Services, Inc.
    > > Augusta, Georgia

    >
    >
     
    Art Cabot, Feb 8, 2005
    #4
  5. Hey Art,

    Thanks for reporting back.

    Good luck!

    Ken

    "Art Cabot" <> wrote in message
    news:...
    > Thanks, Ken. It works great!
    >
    > Art
    >
     
    Ken Cox [Microsoft MVP], Feb 8, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. KathyB
    Replies:
    2
    Views:
    1,931
    Mario Vargas
    Jul 17, 2003
  2. TC
    Replies:
    3
    Views:
    3,311
  3. walterbyrd
    Replies:
    1
    Views:
    377
    Damjan
    Apr 10, 2006
  4. Ark Khasin

    Is it just me or just Microsoft?

    Ark Khasin, Jul 15, 2007, in forum: C++
    Replies:
    24
    Views:
    763
    Lionel B
    Jul 16, 2007
  5. Valli
    Replies:
    3
    Views:
    849
    Maximiliano
    Nov 2, 2007
Loading...

Share This Page