Saturday, March 31, 2012

Storing/Retrieving Objects in the Session

I have a form set up currently so that when someone is added, an object is created with that persons information, and that object is then added to the Session. When the user is done with the form, I have the code setup to mirror the information back on a webpage (when I know it's spewing back the same information I put in, then I'll have it be stored in a database). The problem I am having is that I don't know how to call my toString method of my object from the session.
The class is called Person, and the object is called objPerson, I store it this way:

Session.Add("objPerson", objPerson)

and echo it back to the screen this way:

Response.Write(Session.Item("objPerson"))

The only thing that comes out is the name of the object though, with the namespaces ( COCO.objects.Person ). I tried using

Response.Write( Session.Item( "objPerson.toString()") )

But I had a feeling that wouldn't work, and it didn't. Have I approached this wrong, or am I on the right track here?
Thanks,
DSimmonHi there...

The problem is that you have to sat your item from the session to the Object type of that item, and then you can use it.

Assuming that the class of objPerson is "Person", you would have to do something like this to retreive it:

Person sessionPerson = (Person)Session("Person");

And then use 'sessionPerson' as you want to.

You can use it directly also like this:

((Person)Session("Person")).Name;

Again, assuming you have a "Name" for your "Person" class.

I hope this helps, let me know if you need more info.

Covo
Ahh, so I have to make a storage when I retrieve the object from the session, then recast it to that object type before I use it.
That makes sense, I'll try it now.
Thanks for you help.

David
you're welcome!

Notice that you don't have to make a storage object... If you see the second method I listed, you'll see that you can just cast the session to the object and use it directly.

Story Ads

Hi,

We have all seen them. Those square ads inside of textual content wherethe text wraps around the ad. The ad is about halfway down the text andit floats either left, or right.

What would be the best way to do those kinds of ads? I imagine youcould take the text and count to...let's say 300 characters from theleft, insert the ad and then pick up the text starting at position 301.This seems crude and might cause problems. If the text includes htmltags, position 300 may be an opening, or closing caret, which wouldmess with the formatting.

Any ideas on how to do this in a more elegant way?

Thanks!

<img align=right src="http://pics.10026.com/?src=somepage.aspx">

This will wrap text around it, aligning it on the right and let you use "somepage.aspx" to generate the ad

Straight ASP problem

Hi there.
I am having a weird problem. Currently I have a straight ASP page that
queries an Access database and returns the large recordset on a page that
loops through the recordset and writes the appropriate <td> tags in order to
put the data into a table. Now when I run it in my test environment it runs
no problem, however when I upload to my ISP I get a iis 500 error. But no
error on test server.
A few things: I have noticed that if I decrease the the number of
Response.Write and rstSearch.Fields("FIeldName") code lines that it works
ok on the ISP server.
Any ideas?
JoePart of the web configuration in IIS is the time allowed for a page to run.
If it goes beyond say 900 seconds IIS thinks it's hit an error and declares
a problem.
Another part of the configuration tells IIS what to do with errors; either
give an unhelpful 'an error occurred...' message or give full details to
help the developer figure out what went wrong. In a production environment
IIS is usually set to give no help to potential hackers.
It may simply be that having so many response.write lines in your page takes
too long to process. That would explain why removing some of them fixes the
problem.
Suggestions:
Increase the time-out period by alering the config on your IIS server.
Decrease the size of the recordset. Maybe use paging?
Brian Lowe
--@.
"Joe Coppola" <jocojr@.hotmail.com> wrote in message
news:OyBzKycUEHA.3420@.TK2MSFTNGP12.phx.gbl...
> Hi there.
> I am having a weird problem. Currently I have a straight ASP page that
> queries an Access database and returns the large recordset on a page that
> loops through the recordset and writes the appropriate <td> tags in order
to
> put the data into a table. Now when I run it in my test environment it
runs
> no problem, however when I upload to my ISP I get a iis 500 error. But no
> error on test server.
> A few things: I have noticed that if I decrease the the number of
> Response.Write and rstSearch.Fields("FIeldName") code lines that it works
> ok on the ISP server.
> Any ideas?
> Joe
>
Brian,
Thanks for the reply. I too thought about the timeout setting, but
interestingly I changed the timeout setting on my test server to be like 1
second and I dont get the error, the page just doesnt finish loading
completely. Note I also set the timeout or ASP pages as well.
Is there a way to get a more complete error message?
You are correct the # of response lines is sort of the cause, and I have
thought of paging the results, however, I need the users to be able to
export the whole results to another program... any ideas of this?
Well thanks for the help.
Joe
"Brian Lowe" <no@.reply.address> wrote in message
news:%23ZJsgHeUEHA.2580@.TK2MSFTNGP12.phx.gbl...
> Part of the web configuration in IIS is the time allowed for a page to
run.
> If it goes beyond say 900 seconds IIS thinks it's hit an error and
declares
> a problem.
> Another part of the configuration tells IIS what to do with errors; either
> give an unhelpful 'an error occurred...' message or give full details to
> help the developer figure out what went wrong. In a production environment
> IIS is usually set to give no help to potential hackers.
> It may simply be that having so many response.write lines in your page
takes
> too long to process. That would explain why removing some of them fixes
the
> problem.
> Suggestions:
> Increase the time-out period by alering the config on your IIS server.
> Decrease the size of the recordset. Maybe use paging?
> Brian Lowe
> --@.
> "Joe Coppola" <jocojr@.hotmail.com> wrote in message
> news:OyBzKycUEHA.3420@.TK2MSFTNGP12.phx.gbl...
that
order
> to
> runs
no
works
>

Straight ASP in VS.NET Question

All,
I have to set up a web server to handle
the following call:
<server URL>/Submit.asp?parm1={1}&parm2={2}&parm3={3}
I'm pretty lightweight in ASP.NET and a pure noob
in straight ASP. What's the easiest way to set
up a simple server page to grab these three parms
and invoke a method in my managed assembly?
Thank you,
~swoozin the page_load just add some Request.QueryString() calls, maybe a simple
switch() statement.
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"swoozie" <swooziep@.yahoo.com> wrote in message
news:1111071784.152396.227780@.o13g2000cwo.googlegroups.com...
> All,
> I have to set up a web server to handle
> the following call:
> <server URL>/Submit.asp?parm1={1}&parm2={2}&parm3={3}
> I'm pretty lightweight in ASP.NET and a pure noob
> in straight ASP. What's the easiest way to set
> up a simple server page to grab these three parms
> and invoke a method in my managed assembly?
> Thank you,
> ~swooz
>
Curt_C [MVP] wrote:
> in the page_load just add some Request.QueryString() calls, maybe a
simple
> switch() statement.
> --
> Curt Christianson
> Site & Scripts: http://www.Darkfalz.com
> Blog: http://blog.Darkfalz.com
>
Curt, thanks for the reply. I am still unsure
how to handle the "Submit.asp" in the URL. Do
I need to create a straight ASP page to handle
this? And there's the issue with ending up
in managed code with the parm values.
Thanks a lot!
~swooz
It's all yours now, Curt. -)
Kevin Spencer
Microsoft MVP
.Net Developer
What You S Is What You Get.
"swoozie" <swooziep@.yahoo.com> wrote in message
news:1111076028.221406.316920@.f14g2000cwb.googlegroups.com...
> Curt_C [MVP] wrote:
> simple
> Curt, thanks for the reply. I am still unsure
> how to handle the "Submit.asp" in the URL. Do
> I need to create a straight ASP page to handle
> this? And there's the issue with ending up
> in managed code with the parm values.
> Thanks a lot!
> ~swooz
>
huh? that makes little sense to me.....
Is this .ASP or .ASPX where you are trying to read the querystring values?
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"swoozie" <swooziep@.yahoo.com> wrote in message
news:1111076028.221406.316920@.f14g2000cwb.googlegroups.com...
> Curt_C [MVP] wrote:
> simple
> Curt, thanks for the reply. I am still unsure
> how to handle the "Submit.asp" in the URL. Do
> I need to create a straight ASP page to handle
> this? And there's the issue with ending up
> in managed code with the parm values.
> Thanks a lot!
> ~swooz
>
I got the feeling I missed something, but thanks for the warning :}
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
news:eKvNk0wKFHA.2648@.TK2MSFTNGP14.phx.gbl...
> It's all yours now, Curt. -)
> --
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> What You S Is What You Get.
> "swoozie" <swooziep@.yahoo.com> wrote in message
> news:1111076028.221406.316920@.f14g2000cwb.googlegroups.com...
>
I'm sorry if I wasn't clear. The HTTP GET is from a 3rd-party
client, so I have to handle the URL with ".asp" in it (see above).
If I can handle that with ASP.NET, great! Can I set up a redirect
to an ASPX? Either way, I need to end up with the parms
in a managed assembly, be it web tier or middle. I'm fairly new
to this, so apologies in advance. And thanks so much for the help.
~swooz
One more post to further clarify! ;-)
I am assuming since they're throwing ".asp" at me
that I need to have a classic ASP page on the web
server.
you mean that THEY are pointing to YOUR site like this:
http://www.yoursite.com/submit.asp?parm1={1}&parm2={2}&parm3={3}
If so, few things...
1) wrong group, this is a .NET group.
2) you will need a page on your server called "submit.asp"
3) in that page you will need:
- myValue1 = Request.QueryString("param1")
- myValue2 = Request.QueryString("param2")
- myValue3 = Request.QueryString("param3")
that clarify it for ya?
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"swoozie" <swooziep@.yahoo.com> wrote in message
news:1111079290.380858.246130@.f14g2000cwb.googlegroups.com...
> One more post to further clarify! ;-)
> I am assuming since they're throwing ".asp" at me
> that I need to have a classic ASP page on the web
> server.
>
Yes, it does clarify, thanks. I did the .NET
newsgroup b/c [so far] I've written a pure .NET
app, but it appears I'm gonna have to have
an unmanaged piece in there.
ty

Straight ASP in VS.NET Question

All,

I have to set up a web server to handle
the following call:

<server URL>/Submit.asp?parm1={1}&parm2={2}&parm3={3}

I'm pretty lightweight in ASP.NET and a pure noob
in straight ASP. What's the easiest way to set
up a simple server page to grab these three parms
and invoke a method in my managed assembly?

Thank you,
~swoozin the page_load just add some Request.QueryString() calls, maybe a simple
switch() statement.

--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com

"swoozie" <swooziep@.yahoo.com> wrote in message
news:1111071784.152396.227780@.o13g2000cwo.googlegr oups.com...
> All,
> I have to set up a web server to handle
> the following call:
> <server URL>/Submit.asp?parm1={1}&parm2={2}&parm3={3}
> I'm pretty lightweight in ASP.NET and a pure noob
> in straight ASP. What's the easiest way to set
> up a simple server page to grab these three parms
> and invoke a method in my managed assembly?
> Thank you,
> ~swooz
Curt_C [MVP] wrote:
> in the page_load just add some Request.QueryString() calls, maybe a
simple
> switch() statement.
> --
> Curt Christianson
> Site & Scripts: http://www.Darkfalz.com
> Blog: http://blog.Darkfalz.com

Curt, thanks for the reply. I am still unsure
how to handle the "Submit.asp" in the URL. Do
I need to create a straight ASP page to handle
this? And there's the issue with ending up
in managed code with the parm values.

Thanks a lot!
~swooz
It's all yours now, Curt. -)

--

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"swoozie" <swooziep@.yahoo.com> wrote in message
news:1111076028.221406.316920@.f14g2000cwb.googlegr oups.com...
> Curt_C [MVP] wrote:
>> in the page_load just add some Request.QueryString() calls, maybe a
> simple
>> switch() statement.
>>
>> --
>> Curt Christianson
>> Site & Scripts: http://www.Darkfalz.com
>> Blog: http://blog.Darkfalz.com
>>
>>
> Curt, thanks for the reply. I am still unsure
> how to handle the "Submit.asp" in the URL. Do
> I need to create a straight ASP page to handle
> this? And there's the issue with ending up
> in managed code with the parm values.
> Thanks a lot!
> ~swooz
huh? that makes little sense to me.....
Is this .ASP or .ASPX where you are trying to read the querystring values?

--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com

"swoozie" <swooziep@.yahoo.com> wrote in message
news:1111076028.221406.316920@.f14g2000cwb.googlegr oups.com...
> Curt_C [MVP] wrote:
>> in the page_load just add some Request.QueryString() calls, maybe a
> simple
>> switch() statement.
>>
>> --
>> Curt Christianson
>> Site & Scripts: http://www.Darkfalz.com
>> Blog: http://blog.Darkfalz.com
>>
>>
> Curt, thanks for the reply. I am still unsure
> how to handle the "Submit.asp" in the URL. Do
> I need to create a straight ASP page to handle
> this? And there's the issue with ending up
> in managed code with the parm values.
> Thanks a lot!
> ~swooz
I got the feeling I missed something, but thanks for the warning :}

--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com

"Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
news:eKvNk0wKFHA.2648@.TK2MSFTNGP14.phx.gbl...
> It's all yours now, Curt. -)
> --
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> What You Seek Is What You Get.
> "swoozie" <swooziep@.yahoo.com> wrote in message
> news:1111076028.221406.316920@.f14g2000cwb.googlegr oups.com...
>>
>> Curt_C [MVP] wrote:
>>> in the page_load just add some Request.QueryString() calls, maybe a
>> simple
>>> switch() statement.
>>>
>>> --
>>> Curt Christianson
>>> Site & Scripts: http://www.Darkfalz.com
>>> Blog: http://blog.Darkfalz.com
>>>
>>>
>>
>> Curt, thanks for the reply. I am still unsure
>> how to handle the "Submit.asp" in the URL. Do
>> I need to create a straight ASP page to handle
>> this? And there's the issue with ending up
>> in managed code with the parm values.
>>
>> Thanks a lot!
>> ~swooz
>>
I'm sorry if I wasn't clear. The HTTP GET is from a 3rd-party
client, so I have to handle the URL with ".asp" in it (see above).
If I can handle that with ASP.NET, great! Can I set up a redirect
to an ASPX? Either way, I need to end up with the parms
in a managed assembly, be it web tier or middle. I'm fairly new
to this, so apologies in advance. And thanks so much for the help.

~swooz
One more post to further clarify! ;-)
I am assuming since they're throwing ".asp" at me
that I need to have a classic ASP page on the web
server.
you mean that THEY are pointing to YOUR site like this:

http://www.yoursite.com/submit.asp?parm1={1}&parm2={2}&parm3={3}

If so, few things...
1) wrong group, this is a .NET group.
2) you will need a page on your server called "submit.asp"
3) in that page you will need:
- myValue1 = Request.QueryString("param1")
- myValue2 = Request.QueryString("param2")
- myValue3 = Request.QueryString("param3")

that clarify it for ya?

--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com

"swoozie" <swooziep@.yahoo.com> wrote in message
news:1111079290.380858.246130@.f14g2000cwb.googlegr oups.com...
> One more post to further clarify! ;-)
> I am assuming since they're throwing ".asp" at me
> that I need to have a classic ASP page on the web
> server.
Yes, it does clarify, thanks. I did the .NET
newsgroup b/c [so far] I've written a pure .NET
app, but it appears I'm gonna have to have
an unmanaged piece in there.

ty
or get them to point to a .aspx page instead

--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com

"swoozie" <swooziep@.yahoo.com> wrote in message
news:1111080239.282185.68350@.l41g2000cwc.googlegro ups.com...
> Yes, it does clarify, thanks. I did the .NET
> newsgroup b/c [so far] I've written a pure .NET
> app, but it appears I'm gonna have to have
> an unmanaged piece in there.
> ty

Straight ASP problem

Hi there.

I am having a weird problem. Currently I have a straight ASP page that
queries an Access database and returns the large recordset on a page that
loops through the recordset and writes the appropriate <td> tags in order to
put the data into a table. Now when I run it in my test environment it runs
no problem, however when I upload to my ISP I get a iis 500 error. But no
error on test server.

A few things: I have noticed that if I decrease the the number of
Response.Write and rstSearch.Fields("FIeldName") code lines that it works
ok on the ISP server.

Any ideas?

JoePart of the web configuration in IIS is the time allowed for a page to run.
If it goes beyond say 900 seconds IIS thinks it's hit an error and declares
a problem.

Another part of the configuration tells IIS what to do with errors; either
give an unhelpful 'an error occurred...' message or give full details to
help the developer figure out what went wrong. In a production environment
IIS is usually set to give no help to potential hackers.

It may simply be that having so many response.write lines in your page takes
too long to process. That would explain why removing some of them fixes the
problem.

Suggestions:

Increase the time-out period by alering the config on your IIS server.

Decrease the size of the recordset. Maybe use paging?

Brian Lowe
---@.

"Joe Coppola" <jocojr@.hotmail.com> wrote in message
news:OyBzKycUEHA.3420@.TK2MSFTNGP12.phx.gbl...
> Hi there.
> I am having a weird problem. Currently I have a straight ASP page that
> queries an Access database and returns the large recordset on a page that
> loops through the recordset and writes the appropriate <td> tags in order
to
> put the data into a table. Now when I run it in my test environment it
runs
> no problem, however when I upload to my ISP I get a iis 500 error. But no
> error on test server.
> A few things: I have noticed that if I decrease the the number of
> Response.Write and rstSearch.Fields("FIeldName") code lines that it works
> ok on the ISP server.
> Any ideas?
> Joe
Brian,

Thanks for the reply. I too thought about the timeout setting, but
interestingly I changed the timeout setting on my test server to be like 1
second and I dont get the error, the page just doesnt finish loading
completely. Note I also set the timeout or ASP pages as well.

Is there a way to get a more complete error message?

You are correct the # of response lines is sort of the cause, and I have
thought of paging the results, however, I need the users to be able to
export the whole results to another program... any ideas of this?

Well thanks for the help.

Joe

"Brian Lowe" <no@.reply.address> wrote in message
news:%23ZJsgHeUEHA.2580@.TK2MSFTNGP12.phx.gbl...
> Part of the web configuration in IIS is the time allowed for a page to
run.
> If it goes beyond say 900 seconds IIS thinks it's hit an error and
declares
> a problem.
> Another part of the configuration tells IIS what to do with errors; either
> give an unhelpful 'an error occurred...' message or give full details to
> help the developer figure out what went wrong. In a production environment
> IIS is usually set to give no help to potential hackers.
> It may simply be that having so many response.write lines in your page
takes
> too long to process. That would explain why removing some of them fixes
the
> problem.
> Suggestions:
> Increase the time-out period by alering the config on your IIS server.
> Decrease the size of the recordset. Maybe use paging?
> Brian Lowe
> ---@.
> "Joe Coppola" <jocojr@.hotmail.com> wrote in message
> news:OyBzKycUEHA.3420@.TK2MSFTNGP12.phx.gbl...
> > Hi there.
> > I am having a weird problem. Currently I have a straight ASP page that
> > queries an Access database and returns the large recordset on a page
that
> > loops through the recordset and writes the appropriate <td> tags in
order
> to
> > put the data into a table. Now when I run it in my test environment it
> runs
> > no problem, however when I upload to my ISP I get a iis 500 error. But
no
> > error on test server.
> > A few things: I have noticed that if I decrease the the number of
> > Response.Write and rstSearch.Fields("FIeldName") code lines that it
works
> > ok on the ISP server.
> > Any ideas?
> > Joe

Strande inheritance problem

I have two classes, one called frame1 and the other frame2.

In frame2 i import the frame1, and i also create an instance of it.

The problem is that in class frame1 i have an control declared:

Public WithEvents labelNameLogin As System.Web.UI.WebControls.Label

And when a try for eg, access to it a get an error:

If vObjFrameBoard.labelNameLogin.Text = "" Then -- error

'some code

Exit Sub

error:Object reference not set to an instance of an object

But if a try to access to an of its variables, declared as public a have no problem.
So where is the problem.

Thanks in advanceDoesnt anybody know how to solve this. I really need your help.
Thx
Thx for your help anyway.

Here is the soluction for the problem i was having.

Public WithEvents TextBox1 As System.Web.UI.WebControls.TextBox = New System.Web.UI.WebControls.TextBox

i tought the instance was done automatically, like when building an stand alone application.