.net - Reference Session.Contents Form A Class?

Aug 6, 2010

This is an ASP.NET 2010 web app written in vb. I use several Session variables. I want to pass them all to a central class and let the class manage them. However, I am having some trouble.

Here is the code on the calling page:

Dim arrGoodSessions() As String ={"nameofsession1", "nameofsession2", "nameofsession3"}
Utilities.ManageSessionVariables(arrGoodSessions)

It calls that static Utilties class. I have set a reference to System.Web. Here is the code in the class:

Imports System.Web
Imports System.Web.SessionState
Imports System.Web.SessionState.HttpSessionState
Imports System.Web.HttpContext

[Code]....

This attempts to simply read in some names of session variables and then cycle through all session variables and remove any I didn't list. This works when all of the cod eis on the page. But when I move this to the class, it doesn't recgonize Session.Contents.

View 3 Replies


Similar Messages:

Visual Studio :: Class Diagram And Show Reference Id Of Other Class?

Jul 12, 2010

am using class diagram of visual studio 2008as you can see the image i need show to user that the period and calendar classes have the idMarket property that refers to market classhow can i do this?

View 1 Replies

Does Static Reference To HttpContext.Current.Session Return Same Session For All Users

Feb 4, 2011

Is there room for issue in the following code in terms of multiple users of the same web application? I mean, I know that a purely static string will be shared across all sessions for a single ASP.NET application, but since this explicitly refers to the Current.Session, even though it is static it seems like it would always refer to the session instance of the "current user." But an error is happening that could be explained by everyone sharing the current value of Mode and thus the most recent change overwriting everyone else's mode value. (As a background: This string is in a Helpers class that is used throughout the application. I do not want to make references to Session["Mode"] throughout the application and do not want to have to pass Session["Mode"] in every method call from an aspx.cs page.)

public static string Mode
{
get
{
var value = HttpContext.Current.Session["Mode"];
return (value ?? string.Empty).ToString();
}
set
{
HttpContext.Current.Session["Mode"] = value;
}
}

View 2 Replies

The Session Contents Do Not Appear In The Content Of The Second Page?

Dec 20, 2010

I put this sessions in the page load of the page I want them to be displayed in, but the session contents appear in the top of my website not in the content what is the problem????

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Response.Write("<h1 align=center>Radiation Calculator</h1>")
Response.Write("<br>Hi Mr/Mrs " & Session("Username"))
Response.Write("<br>The following results have been sent to your Email " & Session("Email"))
Response.Write("<br>Air Traveling Distance " & Session("Air Traveling Disance") & " Km")
Response.Write("<br>You have selected the following Factors: " & Session("Factor0") & " . " & Session("Factor1") & " . " & Session("Factor2") & " . " & Session("Factor3") & " . " & Session("Factor4") & " . " & Session("Factor5") & " . " & Session("Factor6") & " . " & Session("Factor7"))
Response.Write("<br>Total Radiation " & Session("Total Radiation") & " mrem")
Response.Write("<br>Your Life Reduction would be: " & Session("User Life Expectancy In Minutes") & "Mintues " & " " & Session("User Life Expectancy In Hours"))
End Sub

View 1 Replies

Web Forms :: How To Send The Contents Of A Form To A RTF File

Mar 15, 2010

where to start to learn how to send the contents of a form to a RTF file.

View 1 Replies

What Is Difference Between Session.Clear() Versus Session.Contents.Clear()

Jan 5, 2011

What is difference between Session.Clear() vs. Session.Contents.Clear()?

I want to clear all the Session variables.

View 1 Replies

Folder / Contents Of Class Library Appearing In Website Project Of Web Application

Oct 8, 2010

When I make an asp.net web application and add class libraries to the solution, the website project itself has a folder with the same name/contents as the class library.

Eg I make a web application called Test, add a project which is a class library, to the solution, called testAbc, and then there is a folder at the root of the website project called testAbc with the contents of the class lib.

View 4 Replies

Folder / Contents Of Class Library Appearing In Website Project Of Web Application?

Feb 14, 2010

When I make an asp.net web application and add class libraries to the solution, the website project itself has a folder with the same name/contents as the class library.

Eg I make a web application called Test, add a project which is a class library, to the solution, called testAbc, and then there is a folder at the root of the website project called testAbc with the contents of the class lib.

I read why this happens in a book a while ago but can't quite remember now.

View 1 Replies

C# - Store Class Properties In Session And Use Of Session Handler - Is It Good Design

Jul 27, 2010

I have a class called EditMapUtilities. Here are some class properties that I want to persist:

public class EditMapUtlities
{
public static Boolean isInitialEditMapPageLoad
{
get { return SessionHandler.isInitialEditMapPageLoad; }
set { SessionHandler.isInitialEditMapPageLoad = value; }
}
// REST OF CLASS NOT GERMAIN TO DISCUSSION AND OMITTED
}

Here is my SessionHandler Class following the pattern from this post Static Session Class and Multiple Users:
using System.Web.SessionState;

public static class SessionHandler
{
private static HttpSessionState currentSession
{
get
{
if (HttpContext.Current.Session == null)
throw new Exception("Session is not available in the current context.");
else
return HttpContext.Current.Session;
}
}
//A boolean type session variable
private static string _isInitialEditMapPageLoad = "EditMapInitialPageLoad";
public static bool isInitialEditMapPageLoad
{
get
{
if (currentSession[_isInitialEditMapPageLoad] == null)
return true;
else
return (Boolean)currentSession[_isInitialEditMapPageLoad];
}
set
{
currentSession[_isInitialEditMapPageLoad] = value;
}
}
}

I am still learning OOAD. I want to keep relevant properties with relevant classes. I also want to keep all Session stored variables in one place for ease of maintenance and to encapsulate the session keys and calls. I feel like my design is too coupled though. How can I make it more loosely coupled? Is my editMapUtilities class too tightly coupled to the SessionHandler class? How would you do it better?

View 2 Replies

Web Forms :: Control Contents Of Type TextBox Must Be Placed Inside Form Tag

Mar 28, 2012

[URL]....

i have used above code but is giving error

Control 'contentPlaceHolder1_txtName' of type 'TextBox' must be placed inside a form tag with runat=server.

wt should i do

i have copied the above code as it is .

View 1 Replies

Php - Any Reason To Place The Session ID Within A Form As A Hidden Form Field?

Apr 2, 2010

is there any reason for me to place the session ID within a form, as a hidden form field?

View 3 Replies

VS 2005 Insert Reference To VB Class In C#

Mar 3, 2010

Have a C# application. I have made reference to a vb class (.dll) called Cat_Feed_Export_to_JDE and I need to instantiate and call this class with a string parameter. I do not know C# and not sure how to code this.

Code:
public void HandleMessage(Object message)
{
Here, instantiate class and call with string parameter
}

View 10 Replies

Added Reference, Class Is Still Not Defined?

Oct 28, 2010

I have a web site project where I need to use the System.Security.Cryptography.Xml.SignedXml class. I added the Dll System.Security as a reference and imported the namespace into my project. It compiles successfully but when I debug the project I get a compilation error:Compiler Error Message: BC30002: Type 'System.Security.Cryptography.Xml.SignedXml' is not defined.What gives?Edit: I run Windows XP Pro 64bit OS

View 1 Replies

MVC :: Can't Reference To Some Properties In Model Class

Mar 31, 2010

I'm reading a bit of Pro ASP.NET MVC Framework and following a few tutorials written in the book. In the very first tutorial, creating a MVC site for dinner (PartyInvites), I encoutered this problem. While I try to reference some properties from Model class, the compilation error occured. Eg. the following code failed.

[Code]....

and the error message

Compiler Error Message:
CS1061: 'object' does not contain a definition for 'Name' and no extension method 'Name' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?) I imported the Model folder into the controller too. I dunno what I'm missing here. Sorry, if it sounds a bit umm hard to understand cuz I just started picking up MVC this morning. Looking for any input.

View 5 Replies

Web Forms :: Programmatically Reference The Class Name In Code - Behind VB?

Jun 17, 2010

I am writing an application that does it's own logging in a SQL table. On each page, I statically assign this variable: Dim page = "page_01.aspx" I've noticed that page is ALWAYS equal to the name of the Partial Class of the code-behind + the suffix ".aspx" Is there any way to programatically set the string to equal the name of the Partial Class, so I don't have to statically code it on each page? Basically, I want to assign the name of the current class to a string, and append ".aspx" to it. Can I do this, or does that get lost in the compilation?

View 1 Replies

Why Use Reference Of Abstract Class To Create Object

Jul 22, 2010

Why do we use the reference of abstract class (or base class) to create object of it's sub-class. eg: TextWriter is the abstract class for StreamWriter & StreamWriter.

TextWriter writer = new StreamWriter();

why can't we simply use :

StreamWriter writer = new StreamWriter();

View 3 Replies

Web Forms :: Reference Same Csharp Class Files

Jan 20, 2010

i have 2 class file business logic layer in c sharp but my application is in vb.net ie my code (aspx.vb) file contains the code for th epage is it possible to reference the same csharp class files in the .aspx.vb file.

View 12 Replies

C# - How To Add A Reference To A Web Application Project In An Associated Class Library

May 13, 2010

I'm working on an internet application that has been set up as a web SITE project (I know...) in Visual Studio. I need to add additional features/functionality so have added a class library to the project and referred to it in the main web site project.

The issue now arises because I need to make use of core objects which live inside the App_Code directory in the web site project but this project doesn't appear to expose its DLL like web app/ code library projects do. Because of this I can't add a reference to the web site project in the class library to leverage the common site-wide code/objects.

I can't move the stuff out of App_Code so I'm looking for a way to refer to the website project dll from the new class library.

View 3 Replies

Dropdown List As Reference Arugment To A Class?

Jan 15, 2011

i need to search and find in dropdown list in my project a lot of times, so i wrote a function

Public Overloads Function findInList(ByVal strValue As String, ByRef ddl As DropDownList, ByVal findType As ddlFindtype) As Integer
Try
If findType = ddlFindtype.byText Then
Dim li As ListItem = ddl.Items.FindByText(strValue)[code]...

it is in a class and obviously it is not working,the ddl is loaded in a aspx page , and it is passed to this function as reference.the ddl as reference is not containing its values from the aspx page.

i need to what i am doing is correct, or is there any other way to achieve it.

View 2 Replies

DataSource Controls :: Can Not Reference Tableadapters From A .cs Class?

Apr 1, 2010

i've created a dataset, and created inside it a datatable and its table adapter.

when i try to reference the table adapter in a .cs class i get an error message that i'm missing some namespace:

Compiler Error Message: CS0246: The type or namespace name 'DataSet1TableAdapters' could not be found (are you missing a using directive or an assembly reference?)

View 2 Replies

C# - Event Handler Reference From Utility Class?

Jan 19, 2010

I have this method that I'm currently putting in each page I make, I know there should be a good way to move it to a single place for ease of maintenance and simplicity. I'm just not sure how I should handle the event handler. The event handler needs to be on each page, so how would I pass in a reference to the page properly so I can reference the event handler?

private void InsertLinkButton(string text, string id, UpdatePanel updateSummary)
{
LinkButton link = new LinkButton();
link.Text = text;
link.Click += new EventHandler(link_Click); <------
link.CausesValidation = false;
AsyncPostBackTrigger trigger = new AsyncPostBackTrigger();
trigger.ControlID = link.ID = "link" + id;
trigger.EventName = "Click";
Utils.Tag(link, placeHolderSummary);
updateSummary.Triggers.Add(trigger);
}

View 2 Replies

WCF / ASMX :: Creating A Proxy Class Over Web Reference?

May 11, 2010

When should I go for creating a proxy class for a web service and when should I go for adding web reference to web service.

Are there any specific advantages of using proxy class over web reference?

View 1 Replies

Asp.net - Deserialize The JsonResponseItem Class Don't Need The Index Reference?

May 28, 2010

I have a simple class in asp.net mvc that looks like this:

[code]...


It deserializes it so I have to reference everything by index first, because of the list. So if I had a property called "IsValid" I would have to reference it like this "IsValid[0]". I have way too much javascript code to make these changes.How could I deserialize the JsonResponseItem class so I don't need the index reference in there?

View 1 Replies

How To Reference A Field In Another Class In A Separate Aspx Page, Using C#

Aug 19, 2010

I have a 2D array of doubles in my Default class on my Default.aspx.cs page, like so:

protected Double[,] time;

By the time the page loads, I have populated this array from a database. Now, I want to reference this array in another file (Diff.aspx.cs) to avoid visiting the database again. Also, the data is used in a read-only fashion.

View 2 Replies

C# - Reference An ASP Control Inside A Function Or Class Method?

Oct 7, 2010

How do you reference an asp.net control on your page inside a function or a class.
private void PageLoad(object sender, EventArgs e)
{
//An example control from my page is txtUserName
ChangeText(ref txtUserName, "Hello World");
}
private void ChangeText(ref HtmlGenericControl control, string text)
{
control.InnerText = text;
}
Will this actually change the text of the txtUserName control?
I tried this and is working
private void PageLoad(object sender, EventArgs e)
{
ChangeText(txtUserName, "Hello World");
}
private void ChangeText(TextBox control, string text)
{
control.Text = text;
}

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved