Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 1.0
This is the forum to discuss the Wrox book Beginning ASP.NET 1.0 with C# by Chris Goode, John Kauffman, Christopher L. Miller, Neil Raybould, S. Srinivasa Sivakumar, Dave Sussman, Ollie Cornes, Rob Birdwell, Matt Butler, Gary Johnson, Ajoy Krishnamoorthy, Juan T. Llibre, Chris Ullman; ISBN: 9780764543708
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 1.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 7th, 2003, 06:14 PM
Registered User
 
Join Date: Oct 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Kris
Default Ch 10 Problem with global.asax

Hi im new to asp.net programming so this question might sound silly to you but I would really need some help. (Im also from Sweden so my english is not very good)

In the example of creating a simple shopping basket in chapter 10 it says in the end that you can add a global.asax file, in where you could write a message ..."buy some of our products, Bill!". I did this and then I wrote in my session.aspx file <%Session("Message")%>. And when I open my session.aspx file I thought I would see this message displayed but I dont. Is it not supposed to be displayed on the page? If it is, then why isnt it there?
Here is the code I have:
In global.asax:

<script language="VB" runat="server">
Sub Session_OnStart()
Session("Message") = "Buy some of our products, Bill!"
End Sub
</script>


In session.aspx:

<%@ Page language="VB"%>
<script language="vb" runat="server">

  Sub EmptyClick(sender As System.Object, e As System.EventArgs)
    Session("BasketCount") = 0
  End Sub

  Sub AddClick(sender As System.Object, e As System.EventArgs)
    Session("BasketCount") += 1
  End Sub
</script>
<html>
  <body>
    <form id="BasketForm" method="post" runat="server">
      <asp:Button id="Empty" OnClick="EmptyClick" runat="server" Text="Empty"/>
      <br />
      <asp:Button id="Add" OnClick="AddClick" runat="server" Text="Add"/>
      <br />
      Basket items : <%=Session("BasketCount")%>
      <br />

    </form>
<%=Session("Message")%>
  </body>
</html>


I would be really grateful for an answer

Kris

 
Old October 8th, 2003, 09:39 AM
Authorized User
 
Join Date: Oct 2003
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Okay I used the code you provided and it works just fine on my machine. So make sure that the Global.asax file is in the same folder as your other file. This should solve the problem. If not let me know.

Jason

"Is the glass half full, half empty, or twice as large as it needs to be?"
 
Old October 8th, 2003, 02:36 PM
Registered User
 
Join Date: Oct 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Kris
Default

Thnx for replying!

The two files are located in the same folder so that is not the problem I think. I have a screenshot which shows what is displayed, my two files with code and a directory browse picture. If I could have ur email address I could send it to u and u could take look. (Its 69 K so its not very big)

Thnx very much for ur help.

Kris

 
Old October 10th, 2003, 08:12 PM
Authorized User
 
Join Date: Oct 2003
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I just ran into a problem on my own machine. I killed my computer the other night removing the GRUB Loader for Linux so I’ve had problems with IIS all day long and I’m thinking you should try what I just went through. Here goes. Inside IIS right click on the folder where the asp.net page resides. Then choose properties. On the first tab that is displayed, towards the bottom, there will be an application name text box and a button to the right of the text box called ‘Create’. Click that button and give your program a try again. If the button says ‘Remove’ than I’ll have to think of something else cause that is not the problem. Let me know.

Jason


"Is the glass half full, half empty, or twice as large as it needs to be?"
 
Old October 11th, 2003, 05:46 PM
Registered User
 
Join Date: Oct 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Kris
Default

doesnt need to, ur solution worked! Now it displays everything correctly!

Thnx very much for ur help!

Regards

Kris

 
Old February 15th, 2005, 09:32 PM
Registered User
 
Join Date: Feb 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

My applicaytion in other aspx file cannot access the content on the global.asax file at all.

what might be the problem here?

 
Old May 11th, 2005, 09:37 AM
Registered User
 
Join Date: May 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by aptbid2002
 I just ran into a problem on my own machine. I killed my computer the other night removing the GRUB Loader for Linux so I’ve had problems with IIS all day long and I’m thinking you should try what I just went through. Here goes. Inside IIS right click on the folder where the asp.net page resides. Then choose properties. On the first tab that is displayed, towards the bottom, there will be an application name text box and a button to the right of the text box called ‘Create’. Click that button and give your program a try again. If the button says ‘Remove’ than I’ll have to think of something else cause that is not the problem. Let me know.

Jason


"Is the glass half full, half empty, or twice as large as it needs to be?"





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to declare the global variable in global.asax? calyn_gately ASP.NET 3.5 Basics 0 August 6th, 2008 08:06 PM
what is global.asax? gaurav_jain2403 General .NET 1 February 3rd, 2006 02:40 PM
global.asax ashokparchuri ADO.NET 1 February 25th, 2005 08:40 AM
Ch 10: Problem with shopping cart example code Storm BOOK: Beginning ASP.NET 1.0 0 October 11th, 2004 03:24 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.