Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > No Postback Just Open Another Page

Reply
Thread Tools

No Postback Just Open Another Page

 
 
Art Cabot
Guest
Posts: n/a
 
      02-07-2005
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
 
Reply With Quote
 
 
 
 
Ken Cox [Microsoft MVP]
Guest
Posts: n/a
 
      02-07-2005
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:9F9DFD61-20D0-498A-8161-...
> 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


 
Reply With Quote
 
 
 
 
Mohamed El Ashmawy
Guest
Posts: n/a
 
      02-08-2005
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

 
Reply With Quote
 
Art Cabot
Guest
Posts: n/a
 
      02-08-2005
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:9F9DFD61-20D0-498A-8161-...
> > 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

>
>

 
Reply With Quote
 
Ken Cox [Microsoft MVP]
Guest
Posts: n/a
 
      02-08-2005
Hey Art,

Thanks for reporting back.

Good luck!

Ken

"Art Cabot" <> wrote in message
news:775BDC56-9E63-44AC-8B0F-...
> Thanks, Ken. It works great!
>
> Art
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
need to open the aspx page in another window(just as popup) Valli ASP .Net 3 11-02-2007 01:04 PM
How to Redirect to Another Already Open Page (Managing Multiple Open Pages in ASP.Net) TC ASP .Net 3 12-07-2004 07:10 AM
How to make a page stay open only for few soconds, then redirect automaticaly to another page NWx ASP .Net 3 02-16-2004 05:21 PM
why window.open script not firing? just postback...continuation of previous post KathyB ASP .Net 2 07-17-2003 02:21 PM
Passing value from one script on one page to another script on another page. Robert Cohen ASP General 3 07-15-2003 01:46 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57