Showing posts with label page_load. Show all posts
Showing posts with label page_load. Show all posts

Thursday, March 29, 2012

Passing values between two pages

Hi

In my source page I am using;

Context.Items("Msg") = Msg
Response.Redirect("Destination_Page.aspx")

In my destination page in Page_Load event I am using;

lblMsg.Text = CType(Context.Items("Msg"), String)

But the value does not get to the destination page. Is there a more
reliable way to pass a string between pages?

Thanks

RegardsTry a Server.Transfer("WebForm2.aspx");
instead of Redirect.

Note this technique does not work if you use Response.Redirect. A Redirect
results in another round trip to the client and a new HTTP request - thus a
new Context object without our ArrayList. To span requests, you'll need to
use the Session object or another state container. Also, there are other
techniques you can use to pass state between two forms when using
Server.Transfer, these other techniques can be found in the resources
section of the article.
http://www.odetocode.com/Articles/111.aspx
"John" <John@.nospam.infovis.co.ukwrote in message
news:eqgC28EpGHA.504@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

Hi
>
In my source page I am using;
>
Context.Items("Msg") = Msg
Response.Redirect("Destination_Page.aspx")
>
In my destination page in Page_Load event I am using;
>
lblMsg.Text = CType(Context.Items("Msg"), String)
>
But the value does not get to the destination page. Is there a more
reliable way to pass a string between pages?
>
Thanks
>
Regards
>
>


If you use Server.Transfer then on the next page you can reference the
PreviousPage object and use the FindControl method to gain reference to
whatever control you want on the previous page (the one that did the
transfer).

--
-Demetri

"sloan" wrote:

Quote:

Originally Posted by

Try a Server.Transfer("WebForm2.aspx");
instead of Redirect.
>
>
Note this technique does not work if you use Response.Redirect. A Redirect
results in another round trip to the client and a new HTTP request - thus a
new Context object without our ArrayList. To span requests, you'll need to
use the Session object or another state container. Also, there are other
techniques you can use to pass state between two forms when using
Server.Transfer, these other techniques can be found in the resources
section of the article.
http://www.odetocode.com/Articles/111.aspx
>
"John" <John@.nospam.infovis.co.ukwrote in message
news:eqgC28EpGHA.504@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

Hi

In my source page I am using;

Context.Items("Msg") = Msg
Response.Redirect("Destination_Page.aspx")

In my destination page in Page_Load event I am using;

lblMsg.Text = CType(Context.Items("Msg"), String)

But the value does not get to the destination page. Is there a more
reliable way to pass a string between pages?

Thanks

Regards


>
>
>

Wednesday, March 21, 2012

Passing variables in .vb page_load event to .aspx file

Hello.
In my page_load event of my web form i check against a database to see if a particular record exists and return a boolean.
How do i get my aspx to check that boolean to determine what to display on the screen.?I would have something like:


// pseudo code

page_load()
{
// get from database

bool doesExist = databasecall();

if (doesExist)
continueSuccessfulDraw();
else
continueUnsuccessfulDraw();
}

Does that help?
You can also do this from within the method that handles the page_load event. One option would be to put a Placeholder control on your .aspx page in the location that you'd want to put whatever it is that is dependent on the boolean you are checking -- and then load the specific controls used for display into the Placeholder.
u need to use web controls
based on the value from the database you can set the visible property true/false

can you give some more details like exactly what you want to display?