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"))

0 comments:

Post a Comment