home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Join TechIMO for Free!
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
Reply Get bargains at  »  Dealighted.com
 
Thread Tools
Currently Active Users: 1759
Discussions: 188,404, Posts: 2,243,610, Members: 232,631
Old April 24th, 2004, 08:14 PM   Digg it!   #1 (permalink)
Ultimate Member
 
Tekk's Avatar
 
Join Date: Oct 2001
Location: Pasadena, CA
Posts: 2,152
Defaulting to Zero in ASP.NET

Im creating a simple shopping cart application and Im wondering how I can get the text-boxes to default to 0 when the page is first viewed. I've been trying to play with the Page.IsPostBack but no matter what I do it wont recognize what I input. For instance right now I have the following block at the top of my aspx file:

[code]
Sub Page_Load
If Not Page.IsPostback Then
phone307.Text = Session("numCell307")
phone427.Text = Session("numCell427")
phone625.Text = Session("numCell625")
End If
End Sub
[code]


I've tried putting in an Else statement setting the .Text values to 0 but it wont work. Any idea on how to solve it?
__________________
YAH! I knew you'd be jealous

Tekk is offline   Reply With Quote
Old April 24th, 2004, 08:21 PM     #2 (permalink)
Ultimate Member
 
Tekk's Avatar
 
Join Date: Oct 2001
Location: Pasadena, CA
Posts: 2,152
What Im trying to do is on the cart/checkout page I dont want to display anything if the cart is empty. Well I'll display a message saying the cart is empty but I think you get the idea. On the cart page i've tried the following code to see if it would work instead of setting values to "0"


If (Session("numCell307") != "") Then
....cart is empty.....
End If

Above gives me a compilation error

I've also tried assigning the value to something as in:

Dim qty307 As String = Session("numCell307")

If (CInt(qty307) > 0) Then
.....show contents.....
Else: nothing
End If

this one gives me an invalid cast because you cant cast a "" to an int (obviously). Although now that I think about it...I could just do it where:

Dim qty307 As String = Session("numCell307")

If (qty307 != "") Then
.....show contents.....
Else nothing
End if

Tekk is offline   Reply With Quote
Old April 24th, 2004, 08:28 PM     #3 (permalink)
Ultimate Member
 
Tekk's Avatar
 
Join Date: Oct 2001
Location: Pasadena, CA
Posts: 2,152
Well Im retarded and figured out my second post's problem:


If Not(qty307 = Nothing) then
..............
End if

Tekk is offline   Reply With Quote
Old April 26th, 2004, 04:58 AM     #4 (permalink)
Ultimate Member
 
Tekk's Avatar
 
Join Date: Oct 2001
Location: Pasadena, CA
Posts: 2,152
I'd just like to mention after finishin this little project Im doing with ASP.net that its lame. Maybe its just me, I dont know, but I find ASP.NET not as logical as say classic ASP or even JSP. And what is the big problem with jsp's anyway? Im taking a JSP class right now as well and man is that easy.....sure its a little bit slower but for me (maybe cause I've had more experience in java) its the EASIEST to code.
Tekk is offline   Reply With Quote
Old April 29th, 2004, 01:21 AM     #5 (permalink)
Member
 
Join Date: Sep 2002
Posts: 364
The != operator does not exist in Visual Basic. Its <>. You were mixing C# style syntax with Visual Basic.

ASP.Net is way more logical than classic ASP. Its object oriented.

It would be sad if there were not many choices to code in for server based web languages.
Creosote is offline   Reply With Quote
Old May 2nd, 2004, 05:19 PM     #6 (permalink)
Ultimate Member
 
Tekk's Avatar
 
Join Date: Oct 2001
Location: Pasadena, CA
Posts: 2,152
I finally noticed that

!= also exists in java

It sometimes gets confusing when Im taking a VBScript class, a VB.NET class, and a JSP class......I get em all mixed!!!

Its gotta be the way the teacher is teaching it because he's making ASP.NET seem way more confusing than it probably needs to be. I agree that object oriented is 10x better

Here's a question: can you pass an arraylist in a session variable in asp.net? the few times I tried it I would successfully fill the arraylist, assign it to a session variable, but then when I try to get the session variable in the next page (ie Dim aList as ArrayList = Session("sessionList")) it returns a 0 count when there should be several things in it. Anyone work with arraylists in ASP.NET before?

Last edited by Tekk : May 2nd, 2004 at 05:29 PM.
Tekk is offline   Reply With Quote
Old May 2nd, 2004, 07:48 PM     #7 (permalink)
Member
 
Join Date: Sep 2002
Posts: 364
I have never tried it. But it should work. I have seen samples I believe where a DataSet was used as a session variable. A DataSet would more or less be similar to a collection.
Creosote is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Most Active Discussions
Is It Just Me? (2906)
Unarmed man on his stomach shot by .. (6)
Misery Loves Company... (2144)
New Build ( Finally ) (7)
CPU wont boot (7)
Building a gaming computer advice (5)
I think I just killed my computer w.. (24)
RCA 52Inch HDTV wont turn on (5)
Folderchat Weekday thread (444)
Recent Discussions
Please help! multiple problems! (4)
How to transfer music from iPod.. (0)
How to Free Convert FLV to DVD .. (0)
RCA 52Inch HDTV wont turn on (5)
New Build ( Finally ) (7)
Common Spyware Solutions (97)
How do you move a hard-drive to.. (4)
Laptop proccesor to desktop mob.. (1)
What is the best external enclo.. (0)
Blackberry Storm, Gears of War .. (1)
Core 2 Quad Q9550 system (3)
COWBOOM Ripoff! Used Laptop w/$.. (4)


All times are GMT -4. The time now is 03:53 AM.
TechIMO Copyright 2008 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28