ASP Question

G

Gunawan

Hi There....
My name is Gunawan. I am new to ASP 2.0 Programming.
I would like to have to separate web page.
one.aspx and two.aspx
when click a button on one.aspx it will open two.aspx but I would like to
send value from tpertama.text in one.aspx to two.aspx.
how can I do that and two.aspx could read that value. in vb 6 I could easily
called frmOne.tpertama.text from two.aspx
and when I back to one.aspx. value from tkedua.text on two.aspx could be
read from one.aspx.

In vb 6 I will open two.frm as dialog then when return I issue hide method
and from one.frm I read value from two.frm and close it.
How can I do in this asp?

Regards,
Gun
 
T

Tasos Vogiatzoglou

In your button you should use the PostbackURL attribute. Like this :
<asp:Button ID="MyButton" PostBackUrl="two.aspx" runat="server" />


Regards,
Tasos
 
G

Gunawan

Tasos,

How can I read value from tone.text (tone is a textbox) in one.aspx
from page load on two.aspx?

Regards,
Gun
 
G

Gunawan

But I've got this error
Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: CS0118: 'System.Web.UI.Page.IsPostBack' is a
'property' but is used like a 'method'

Source Error:



Line 14: protected void Page_Load(object sender, EventArgs e)
Line 15: {
Line 16: if (IsPostBack())
Line 17: {
Line 18: tTwo.Text = Request.Params["tOne"].ToString();
 
D

David

if (IsPostBack)

not if (IsPostBack())

(Note: No brackets...)
--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available


Gunawan said:
But I've got this error
Compilation Error
Description: An error occurred during the compilation of a resource
required to service this request. Please review the following specific
error details and modify your source code appropriately.

Compiler Error Message: CS0118: 'System.Web.UI.Page.IsPostBack' is a
'property' but is used like a 'method'

Source Error:



Line 14: protected void Page_Load(object sender, EventArgs e)
Line 15: {
Line 16: if (IsPostBack())
Line 17: {
Line 18: tTwo.Text = Request.Params["tOne"].ToString();


Tasos Vogiatzoglou said:
Request.Parameters["tone"]
 
H

Hans Kesting

In vb 6 I will open two.frm as dialog then when return I issue hide method
and from one.frm I read value from two.frm and close it.
How can I do in this asp?

This works very differently in web programming. Here the pages live
just for a short while, from when it starts handling the Request to
when it is done sending the Response. There is no way to an instance of
some other page, as that instance isn't there anymore.
You can transfer values from one page to another via the "querystring",
the part after the "?".
For instance in "page1.aspx" you execute
Response.Redirect("page2.aspx?val=10");
Then in page2.aspx you can read it with Request["val"] (note: this will
give you a string).

A different way is to store it in Session: Session["val"] = 10;
It's stored as an "object" so you need to cast it when you retrieve the
value. This Session object is specific to the browser requesting the
page.

Note: be careful with "static" values, they are available to the entire
(web-)application, which can be serving requests for any number of
concurrent users. They will all see the same value.

Hans Kesting
 
G

Gunawan

It is look like we should have a new programming trick while using ASP.NET.
I have a few more question if you don't mind.
1. If pages only live for short time, how about the dataset object that we
have populate?
I believe if I postisback the page the dataset object still hold the
same value unless we go to another pages?
2. Can we go to certain pages using btn_click event code instead using
<asp:... PostBackUrl="xxx.aspx" .../>?

Thank you.
Regards,
Gunawan

Hans Kesting said:
In vb 6 I will open two.frm as dialog then when return I issue hide
method and from one.frm I read value from two.frm and close it.
How can I do in this asp?

This works very differently in web programming. Here the pages live just
for a short while, from when it starts handling the Request to when it is
done sending the Response. There is no way to an instance of some other
page, as that instance isn't there anymore.
You can transfer values from one page to another via the "querystring",
the part after the "?".
For instance in "page1.aspx" you execute
Response.Redirect("page2.aspx?val=10");
Then in page2.aspx you can read it with Request["val"] (note: this will
give you a string).

A different way is to store it in Session: Session["val"] = 10;
It's stored as an "object" so you need to cast it when you retrieve the
value. This Session object is specific to the browser requesting the page.

Note: be careful with "static" values, they are available to the entire
(web-)application, which can be serving requests for any number of
concurrent users. They will all see the same value.

Hans Kesting
 
H

Hans Kesting

It is look like we should have a new programming trick while using ASP.NET.
I have a few more question if you don't mind.
1. If pages only live for short time, how about the dataset object that we
have populate?
I believe if I postisback the page the dataset object still hold the same
value unless we go to another pages?

Usually you will have to re-read the values, or you can store them in
ViewState (only valid for postbacks = to the same page and user),
Session (avaliable from any page for this particular user) or even
Cache (avaliable to anyone from any page)
2. Can we go to certain pages using btn_click event code instead using
<asp:... PostBackUrl="xxx.aspx" .../>?

The regular way is Response.Redirect("otherpage.aspx");
Thank you.
Regards,
Gunawan

Hans Kesting said:
In vb 6 I will open two.frm as dialog then when return I issue hide method
and from one.frm I read value from two.frm and close it.
How can I do in this asp?

This works very differently in web programming. Here the pages live just
for a short while, from when it starts handling the Request to when it is
done sending the Response. There is no way to an instance of some other
page, as that instance isn't there anymore.
You can transfer values from one page to another via the "querystring", the
part after the "?".
For instance in "page1.aspx" you execute
Response.Redirect("page2.aspx?val=10");
Then in page2.aspx you can read it with Request["val"] (note: this will
give you a string).

A different way is to store it in Session: Session["val"] = 10;
It's stored as an "object" so you need to cast it when you retrieve the
value. This Session object is specific to the browser requesting the page.

Note: be careful with "static" values, they are available to the entire
(web-)application, which can be serving requests for any number of
concurrent users. They will all see the same value.

Hans Kesting
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top