Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 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 August 1st, 2004, 01:52 PM
Authorized User
 
Join Date: Jul 2004
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default Another Session Variable Problem

Hi All,

Here is another problem I am having with passing session variables:
I simply want to pass one variable called Department to the next page. Unfortunately, the next page does not show it in the datagrid (using Dreamweaver).

On line 2 of my code, I have...
<script language="VB" runat="server">
Sub SetSessionVariable_Click(ByVal s As Object, ByVal e As EventArgs)
Session("sessDepartment") = Request("tfDepartment")
Session("sessEditPages") = Request("tfEditPages")
Response.Redirect("Page_Manager.aspx")
End Sub
</script>

The code for the textboxes and buttons that the user inputs is as follows:
          <form name="form1" method="post" action="" runat = "server">
            <table width="300" border="1" cellspacing="1" cellpadding="1">
              <tr>
                <td class="BodyText">sessDepartment:</td>
                <td><asp:TextBox ID="tfDepartment" runat="server" /></td>
              </tr>
              <tr>
                <td class="BodyText">sessEditPages:</td>
                <td><asp:TextBox ID="tfEditPages" runat="server" /></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td><asp:Button ID="btSubmit" Text="Set Variables" runat="server" onClick="SetSessionVariable_Click"/></td>
              </tr>
            </table>
          </form>

The next page should show the user's department in the department field, but it doesn't???

Any help on this would be great!
Thx,
Jim




 
Old August 1st, 2004, 06:22 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

Why not do it as:

Session("sessDepartment") = tfDepartment.Text
Session("sessEditPages") = tfEditPages.Text

Request is the ASP3 way of doing things...

Brian
 
Old August 1st, 2004, 10:40 PM
Authorized User
 
Join Date: Jul 2004
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Brian,

Thanks for the reply. This one has me stumped pretty bad. I tried what you suggested, but it didn't work. If you or anyone else has any idea why my session variables are not working, I would be forever in your debt.
Is it possible that I have something configured incorrectly with my server??

Anyway, here is my code for the 2 pages: (Set_Session.aspx and Page_Manager.aspx):

Here is the Set_Session.aspx Page:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<script language="VB" runat="server">
Sub SetSessionVariable_Click(ByVal s As Object, ByVal e As EventArgs)
Session("sessDepartment") = tfDepartment.Text
Session("sessEditPages") = tfEditPages.Text
Response.Redirect("Page_Manager.aspx")
End Sub
</script>
<html>

          <p align="center" class="HEADERTEXT">Authorization Test </p>
          <form name="form1" method="post" action="" runat = "server">
            <table width="300" border="1" cellspacing="1" cellpadding="1">
              <tr>
                <td class="BodyText">sessDepartment:</td>
                <td><asp:TextBox ID="tfDepartment" runat="server" /></td>
                </tr>
              <tr>
                <td class="BodyText">sessEditPages:</td>
                <td><asp:TextBox ID="tfEditPages" runat="server" /></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td><asp:Button ID="btSubmit" Text="Set Variables" runat="server" onClick="SetSessionVariable_Click"/></td>
              </tr>
            </table>
          </form>
          <p align="center" class="HEADERTEXT">&nbsp;</p>



************************************************** *************
And here is the Page_Manager.aspx Page:
************************************************** *************

<%@ Page Language="VB" ContentType="text/html" %>
<%@ Register TagPrefix="MM" Namespace="DreamweaverCtrls" Assembly="DreamweaverCtrls,version=1.0.0.0,publicK eyToken=836f606ede05d46a,culture=neutral" %>
<MM:DataSet
id="dsPages"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_STRING_connLeanSigmaASP") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_DATABASETYPE_connLeanSigmaASP" ) %>'
CommandText='<%# "SELECT Department, PageID, PageTitle FROM TB_PageMgmt WHERE Department = ?" %>'
Debug="true"
>
  <Parameters>
<Parameter Name="@Department" Value='<%# IIf((Not Session("sessDepartment") Is Nothing), Session("sessDepartment"), "") %>' Type="WChar" /></Parameters></MM:DataSet>
<MM:PageBind runat="server" PostBackBind="true" />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>

          <MM:If runat="server" Expression='<%# (session("sessEditPages") = "True") %>'>
              <ContentsTemplate>
              <p align="center" class="HEADERTEXT">We're sorry. You are not authorized to edit Internet Pages. </p>
            </ContentsTemplate>
          </MM:If>
          <MM:If runat="server" Expression='<%# (session("sessEditPages") <> "True") %>'>
            <ContentsTemplate>
              <p align="center" class="HEADERTEXT">PAGE MANAGER </p>
            </ContentsTemplate>
          </MM:If>
          <p align="center" class="HEADERTEXT"><a href="Add_Page.aspx">Click here</a> to add a new page. </p>
          <p align="center" class="HEADERTEXT">
          <form runat="server">
            <asp:DataGrid AllowPaging="false"
  AllowSorting="False"
  AutoGenerateColumns="false"
  CellPadding="3"
  CellSpacing="0"
  DataSource="<%# dsPages.DefaultView %>" id="dgPages"
  runat="server"
  ShowFooter="false"
  ShowHeader="true"
>
              <HeaderStyle HorizontalAlign="center" BackColor="#E8EBFD" ForeColor="#3D3DB6" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Bold="true" Font-Size="smaller" />
              <ItemStyle BackColor="#F2F2F2" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Size="smaller" />
              <AlternatingItemStyle BackColor="#E5E5E5" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Size="smaller" />
              <FooterStyle HorizontalAlign="center" BackColor="#E8EBFD" ForeColor="#3D3DB6" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Bold="true" Font-Size="smaller" />
              <PagerStyle BackColor="white" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Size="smaller" />
              <Columns>
              <asp:BoundColumn DataField="PageID"
        HeaderText="PageID"
        ReadOnly="true"
        Visible="True"/>
              <asp:BoundColumn DataField="Department"
        HeaderText="Department"
        ReadOnly="true"
        Visible="True"/>
              <asp:HyperLinkColumn
        HeaderText="PageTitle"
        Visible="True"
        DataTextField="PageTitle"
        DataNavigateUrlField="PageID"
        DataNavigateUrlFormatString="Edit_Page.aspx?PageID ={0}"/>
              <asp:HyperLinkColumn
        HeaderText="Delete"
        Visible="True"
        Text="Delete"
        DataNavigateUrlField="PageID"
        DataNavigateUrlFormatString="Delete_Page.aspx?Page ID={0}"/>
</Columns>
            </asp:DataGrid>
          </form>
          </p>






 
Old August 2nd, 2004, 04:08 PM
Authorized User
 
Join Date: Jul 2004
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Could anyone help me out with this problem?

Thx,
Jim

 
Old August 3rd, 2004, 03:56 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Jim,

I'm not sure how the calls to the session variables will work function in that MM control. The first thing I would do is get rid of that and use the native .NET classes (System.Data.DataSet) for your grid's datasource in code-behind/inline.
 
Old August 4th, 2004, 01:54 AM
Authorized User
 
Join Date: Jul 2004
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I tried what you suggested, but I am getting no where fast.

I think I actually tried everything here. If I were to email you my Dreamweaver pages, would you be able to take a look?

:(
Jim

 
Old August 6th, 2004, 12:15 AM
Authorized User
 
Join Date: Jul 2004
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi All,

Absolutely great news. I got it working. : -)
Your not going to believe what happened. I actually had everything (the code that is) correct. I had a very good laugh when I figured out that my Firewall was blocking any access of my session variables. I turned my Firewall off and everything worked perfect.....absolutely perfect.

Well, I had a good laugh at myself. I should have known to turn off this program way before I started this webpage design.
Lesson learned I guess......

I just want to say thanks to all for taking the time to help out a beginner. Really appreciate it. I'm sure I'll get stuck on something else (hopefully not the easy stuff). This discussion board is great. Its saving me from pulling out my hair.

Thanks Again,
Jim




 
Old August 6th, 2004, 11:57 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Jim,

Glad to hear that you got it working. However, I'm a little skeptical about something. If you can access the page, but it wasn't working with sessions, I can't see how the firewall would affect it. At least, what I mean is that the firewall can't block the access to the session data as session data access is an internal mechanism of the web server. It is not a function of the client to server conversation. However, the inclusion of cookies within the request is and this is what's enabling the functionality of sessions. So I'm wondering if the firewall is somehow reading and modifying the HTTP request and stripping out or changing the cookies somehow. I have never heard of a firewall doing this, but it's certainly possible. I'm not a network guy so I'm no expert on such matters.
 
Old August 7th, 2004, 12:56 AM
Authorized User
 
Join Date: Jul 2004
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Planoie,

I'm not a network guy either. My Firewall, called "ZoneAlarm", can monitor cookies, ports, program usage, IIS Server rights, software program rights, email and many other functions.

Just by guessing that it had something to do with my frustration over the past week, I decided to modify the ranges for these cookies, ports, and program rights. I then tried my session variable pages again and abracadabra... it worked. I never changed a thing in my code either.

As you mentioned, the firewall must have the capability of reading and modifying HTTP requests or changing the cookies somehow. I'm not sure how or what it does, but believe me, I wasn't complaining.

Jim







Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with session variable prabhatsriva01 ASP.NET 2.0 Professional 3 May 10th, 2007 11:41 AM
Session Variable Problem caterpillar General .NET 0 August 17th, 2006 11:26 AM
Another Session Variable Problem [email protected] Classic ASP Databases 1 August 1st, 2004 03:58 AM
Session Variable Problem leo_vinay Classic ASP Professional 1 October 1st, 2003 10:51 PM





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