Showing posts with label source. Show all posts
Showing posts with label source. Show all posts

Thursday, March 29, 2012

passing values between aspx.vb pages

About javascript window.opener. How do I pass values from source.vb to object.vb if I use window.opener("target.aspx") in a javascript function? I want to use a separate .js file for this purpose.

My code looks something like this.

'Source.aspx
<script ... src="http://pics.10026.com/?src=scripts.js"
<a onclick="newwindow()">text</a
'Source.aspx.vb

variable1 as String
variable2 as Integer

'scripts.js
function newwindow() {
myWin = opener("target.aspx");
}

'Target.aspx.vb

variabletarget1 as String
variabletarget2 as Integer

So, I would like to set variabletarget1 = variable1 and variabletarget2 = variable2 in the process. I am not using frames or iframes. MSDN says that window.opener works only in <frame> or <iframe> pages.

How to do this with javascript?

HenrixHi Henrix,
Somethig like this:


'Source.aspx
<script ... src="http://pics.10026.com/?src=scripts.js"
<a runat="server">text</a
'Source.aspx.vb

variable1 as String
variable2 as Integer
...

a.Attributes.Add("onclick", "newwindow('"& variable1 & "'," & variable2 & ")"

'scripts.js
function newwindow(variable1, variable2) {
myWin = opener("target.aspx?variable1="+variable1+"&variable2="+variable2);
}

'Target.aspx.vb

variabletarget1 as String
variabletarget2 as Integer
...
variabletarget1 = Request.QueryString("variable1")
variabletarget2 = Int32.Parse(Request.QueryString("variable2"))

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


>
>
>

Monday, March 26, 2012

Passing values from one page to another

How do I pass values from one page to another without using a button for redirection. That means on my source page I have a hyperlink that redirects to some target page. I have a label on the source page whose text I want to pass to the target page. How can I do that?

Use the querystring.

http://www.codeproject.com/aspnet/QueryString.asp

Passing values between pages

http://www.firoz.name/2006/05/07/passing-values-between-pages/