Is there a way to do this with Option Strict On?

  • Thread starter Chad Dokmanovich
  • Start date
B

Bruno Alexandre

just an idea why not passing as a Session Variable ?


--

Bruno Alexandre
Strøby, Danmark

"a Portuguese in Denmark"
 
K

Karl Seguin [MVP]

An interface should solve your problem and happens to be the correct
approach to tackle such a problem. Without an interface, you're effectvely
tying default2 to default3 - why not detach it from a concrete class and tie
it to a much more flexible interface?

Since you are vague about what "X" is.....
in your app_code,

interface IXContainer
{
string X {get ;}
}

class default3 : Page, IXContainer
{
...
}


dim passedX as string = ctype(Context.Handler, IXcontainer).X


oopps..I wrote 1/2 of that in C#....anyways, you get the idea...I think it
should work the way you want it to.

Karl
 
S

Samuel R. Neff

Peter's post about using query string or HttpContext.Current.Items is
probably the best advice. Passing data between webforms by relying on
the webforms own properties is pretty ugly, even if it technically
works.

HTH,

Sam
 
C

Chad

Interesting point of view, my perspective was the exact opposite: that
passing values from one form to another using strongly type full-blown
properties (which themseleves could have code in the Get routine) is much
more elegant and preferable method to passing string data via hidden forms
fields or even the Session object, which often ends up being a dumping
ground for all of the pages in the app.

I want to be able to defined a property on the source web page that returns
an object that contains all of the property values that are passed from the
source form to the dest form and to do so in a strongly typed "Parameter
class" that is specific to the two forms in question only.
 
S

Samuel R. Neff

Web forms are not designed for passing strongly typed data to each
other and certainly are not meant for one web form to call properties
in another form. HTTP pages have two well defined ways of passing
data--query string and form variables.

If the data you're passing is more complex than a string, then create
a class to contain the data and put that class in the
HttpContext.Curent.Items collection when passing it, and then cast it
on the receiving page back to the typed class.

Using Session is horrible because the data is not inherintly session
related--you're just passing it from one page to another and dumping
it into the Session is overkill and dangerous).

My $0.02.

Sam


------------------------------------------------------------
We're hiring! B-Line Medical is seeking Mid/Sr. .NET
Developers for exciting positions in medical product
development in MD/DC. Work with a variety of technologies
in a relaxed team environment. See ads on Dice.com.
 
C

Chad Dokmanovich

Interesting!

The HttpContext suggestion sounds like it is just what I am looking for!

I dont like query strings because I dont want users to have an opportunity
to manipulate the data that is passed between the pages. I could encode it,
which is probably always a good idea, although at the moment I am writing
for a mobile device and am concerned about the query string limit for the
browser running on the mobile device.

For mobile forms, there are no hidden text fields, there is a
HiddenVariables collection, and while I can persist data there while posting
back to the same page, I've had no luch using this collection to pass data
across forms (no data found on the receicing side). Seems like it should be
straight fwd but It doesnt work for me and I can't find much on the subject.
Here's a blurb:

http://safari.oreilly.com/0735615322/IDATX2T

I'm excited about and will now try the HttpContext suggestion....thx!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,008
Latest member
HaroldDark

Latest Threads

Top