April 24th, 2004, 08:14 PM
|
#1 (permalink)
| | Ultimate Member
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
|
| |
April 24th, 2004, 08:21 PM
|
#2 (permalink)
| | Ultimate Member
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 |
| |
April 24th, 2004, 08:28 PM
|
#3 (permalink)
| | Ultimate Member
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 |
| |
April 26th, 2004, 04:58 AM
|
#4 (permalink)
| | Ultimate Member
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. |
| |
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. |
| |
May 2nd, 2004, 05:19 PM
|
#6 (permalink)
| | Ultimate Member
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.
|
| |
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. |
| | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | |
Posting Rules
| You may post new threads You may post replies You may not post attachments You may not edit your posts HTML code is Off | | | | Most Active Discussions | | | | | Recent Discussions  | | | | | |