Showing posts with label object. Show all posts
Showing posts with label object. 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"))

Saturday, March 24, 2012

Passing variables between pages

What is the best method to pass variables between pages?
Is it through the Session object with large quantities of data and with the querystring/params with smaller quantities?

Hi smith,

Please have a look at this article.

http://msdn.microsoft.com/msdnmag/issues/03/04/ASPNETUserState/

For a quick reference,

http://msdn.microsoft.com/msdnmag/issues/03/04/ASPNETUserState/default.aspx?fig=true#fig1

HTH.


Yes, that is correct.

and for example when I assign a dataset to a Sessionobject as so:

Session("MyData")=MyDataSet
How can I retreive the data from this in another page? Do I need to create a new dataset object and assign the stored dataset to it, like so:
DataSetInOtherPage = Session("MyData") ?


Peter Smith wrote:

and for example when I assign a dataset to a Sessionobject as so:

Session("MyData")=MyDataSet
How can I retreive the data from this in another page? Do I need to create a new dataset object and assign the stored dataset to it, like so:
DataSetInOtherPage = Session("MyData") ?

Session stores its values as Objects, which means that it can store anything, as everything derives from Object. This means that you must cast the Session item when assigning it to a local variable. For example:

DataSet DataSetInOtherPage = Session["MyData"] as DataSet; [C#]

Dim DataSetInOtherPage As DataSet = CType(Session("MyData"), DataSet) [VB.NET]

passing variables between web page events & httpmodules events

Use the item property on the httpcontext object. It's a dictionary object
which stores key/pair values but it is available every the httpcontext
object is available.

Regards

--

----
Got TidBits?
Get it here: www.networkip.net/tidbits
"shiv" <kadalli@dotnet.itags.org.hotmail.com> wrote in message
news:082a01c3b295$6d2db890$a501280a@dotnet.itags.org.phx.gbl...
> hi all,
> I need to access some variables which are generated in
> preRequestHandler Event in httpModule. I need these
> variables in Page ButtonControl Click event. Is that
> possible? I don't want to use session variables here. has
> anybody got some inputs here.
> Thanks in advance,
> regards
> shivThanks Alvin,
I too found out the same. You reaffirmed my findings!.
Thanks a millon!

regards
shiv
>--Original Message--
>Use the item property on the httpcontext object. It's a
dictionary object
>which stores key/pair values but it is available every
the httpcontext
>object is available.
>Regards
>--
>
>----
>Got TidBits?
>Get it here: www.networkip.net/tidbits
>"shiv" <kadalli@.hotmail.com> wrote in message
>news:082a01c3b295$6d2db890$a501280a@.phx.gbl...
>> hi all,
>>
>> I need to access some variables which are generated in
>> preRequestHandler Event in httpModule. I need these
>> variables in Page ButtonControl Click event. Is that
>> possible? I don't want to use session variables here.
has
>> anybody got some inputs here.
>> Thanks in advance,
>> regards
>> shiv
>>
>
>.

Wednesday, March 21, 2012

PassingObjectstoWebForms

I have an object that gets created when the first ASP.NET webform, of
the web app, is opened. I need to pass this object to other webforms as
they are opened and keep the scope in the same session. How can I do this?

ThanksHI J,

You can store the object into a Session var and pick it up in following
forms. This works well assuming that the object you are storing is
serializable.

If you're using Server.Transfer() or Server.Excute() you can also use
Context.Items() to store request specific info to pass to transferred pages.

+++ Rick --

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
-----------
Making waves on the Web

"J" <j@.netscape.net> wrote in message
news:ODlq6J5AEHA.3400@.tk2msftngp13.phx.gbl...
> I have an object that gets created when the first ASP.NET webform, of
> the web app, is opened. I need to pass this object to other webforms as
> they are opened and keep the scope in the same session. How can I do
this?
> Thanks

Passsing a connection object

I have a class that creates a connection to the database. When I call this object from my aspx code behind to get a connection to the database I get an error.
Object reference not set to an instance of an object.
How can I pass a connction object back from a class to a aspx code behind.pls post some code so that we might see the problem ...
if an object is not marked as Shared, you need to instantiate it before calling any of its methods.

based on your error you may have something like this:

dim oConn as MyConnectionObject
dim something as string
something = oConn.GetConnString

this will fail

you need

dim oConn asNew MyConnectionObject
dim something as string
something = oConn.GetConnString