State Management :: Cant Access Object Property In Class?
Mar 28, 2010
I'm having a problem with a class library I'm building. I have a class called Users and inside this class I have a property called UserInfo that is an object. Both of the classes Users and UserInfo are built using MyGenerations dOOdads. When I create an object instance of the Users class I am able to access the UserInfo property without a problem in my Windows App, however when I using the same library in a website the UserInfo property continues to return a no reference error. Like I said when running it in a WinApp I have no problems at all, I can access the UserInfo property and likewise all of UserInfo's properties. I am also having problems trying to debug the library using the website. And again I have no problems when using the WinApp. The way I've set it up is I have the Class library project open, and then I add the WinApp project and then the website project. When I set the WinApp as the startup project and run it I have no problems, I can set breakpoints and step through the code no problem. But when I set the Website as the startup project and try to debug I get a massage saying the breakpoint won't be hit. I then do what it tells me and right click on the breakpoint and set the location to allow the source to be different. This lets me hit the breakpoint, but every time I hit F10 to step I get "There is no source code available for the current location." For every step I take. This is making it really hard for me to figure out what going on with the code in the website. Sorry for the lengthy explanation. Here's the Users class, again it works great in the WinApp, just not the website.
[Code]....
View 6 Replies
Similar Messages:
Oct 17, 2010
I want to know , how good / bad is it to save configuration values in a static properties?I am creating an application which reads configuration from an XML file and a DataContext file, instead of sending the CustomConfig class into the configuration.xml each time I tought about using an ReadXml() method on application_start at the global.ascx
the ReadXml() method would save the data in static properties of CustomConfig and whereever I would want to read that particler data I would ask CustomConfig.PROERTY_NAME
My question is ? how smart it is ? how long does IIS would save the data in a static member? (if as long as the application exists then I'm ok as long as I add the ReadXml() in the application_start)
View 2 Replies
Nov 5, 2010
I wish to persist a class object across postbacks by using a single session variable/object/whatever.
The class has about a dozen single variable properties; and about a dozen table properties; and several methods. The main table tracks rows of sporting event results. The web site will collect one row at a time for each postback. The data in the object's constructor is based on a dataset, but the data in the class will grow each time I do a postback so I don't want to loose the information in the class. The data isn't very big - it will fill a single computer screen.
Being new to programming I am thinking that I can store the dataset in the session but that would slow down the response time because I the methods would have to be called to refine the data - or maybe I can just store the entire class object in a session.
View 3 Replies
Jun 30, 2010
my solution currently has a website project and a class library project. I am attempting to access a session object from my class library but it is always returning null. In a settings class in my class library I store these values like so:
private static SessionProperty<WebUser> _currentUser = new SessionProperty<WebUser>("CurrentUser", delegate { return new WebUser(); });
public static WebUser CurrentUser
{
get { return _currentUser.Value; }
set { _currentUser.Value = value; }
}
I can access this just fine from any aspx page codebehind like so:
Settings.CurrentUser.User.ProviderUserKey.ToString();
However, if I attempt to do the same thing from a class in my classlibrary project it always returns null.
View 5 Replies
Oct 5, 2010
i have created a user control UserControl.ascx, in Code behind file of UserControl.ascx i have created an object of a class MyClass.cs,
Like
if(!Page.IsPostback) {
objMyClass= new MyClass();
}
but when i click on button of UserControl.ascx page and try to access objMyClass object then it set as null, so how to persist MyClass object when page PostBack, i wanted to keep object persist till the user access the page, when user goes out of this page then object should distroy?
[code].....
View 9 Replies
Sep 1, 2010
I am trying to incorporate AJAX in my web project for the first time and it isn't working. I don't know how to instantiate a class once and use AJAX to update the dataset numerous times before updating the database changes using a postback.
My project is to learn AJAX with a class object. Clicking the button is supposed to increment a count by one using a class to store the count. Here is my class:
[Code]....
Here is my HTML code:
[Code]....
And here are my button click event code snippets:
[Code]....
My problem is that as I step through the code (after clicking on the second button) it instantiates a new class object each time which returns a value of 2 every time. I have tried to fix the problem by putting my counter class instantiation in the pageload event using "If Not IsPostBack Then ..." but my probem there is that the button click event block of code would not recognize the cCount class - it put the blue lines under the cCount
My goal is to have the class object available to multiple events in the code behind: especially using AJAX to build records in one of my DataSet tables Does anyone know how to handle this?
View 6 Replies
Mar 27, 2010
How to access session variable in the class?
View 5 Replies
Mar 30, 2010
I am stuck with the issue of concurrent access to Session object. Actually my problem is i m writing to session in frame1 and trying to access that same Session object at the same time in Frame2's Page. I know about the reader/writer lock. I made the enablesessionstate = readonly in the page where i m writing to session. its giving me strange behavior on IE and firefox.
Its working concurrently in IE8 ( means page2 is diplaying modified values while page1 is changing the session object) but does not work in Firefox even page load is not called untill function on page 1 completed. Either anyone can fix my issue with firefox or there is new solution to reader/writer lock so that i can read the session at the same time while writing.
View 2 Replies
Aug 7, 2010
This source what i have used to create cache object.Also i have checked if "AppCache_Caption" cache object is available or not.
[Code]....
Right now i have checked and created my login page page_load event.It will create cache object every time me access the login page.What are the conditions wrong my source?My expectation, cache object creates only one time.It will not create everytime.
View 4 Replies
May 29, 2010
I am doing a POC of making my website run faster. Currently it stores huge object data in Session while passing information from one page to another. What I was thinking is to use shared methods and properties instead of session. It works, but wanted tocheck if this is an optimum way to do it. Below is the code that does not use session but still pass object data from one page to another:
[code]...
View 1 Replies
Aug 19, 2010
We have an applicaiton that was converted to the new framework using the wizard in Visual Studio 2008. When we install the applicaiton in production and change the iis settings to use the 2.0 framework we start to see these errors in the event viewer on the web servers. We are using SQL Server Session State and have 3 web servers in a load balancer. Object reference not set to an instance of an object.</Message><StackTrace> at System.Web.SessionState.SessionStateModule.PollLockedSessionCallback...
View 1 Replies
Jul 16, 2010
I have a problem.This particular code when used on local machine is working fine, but when it is used on serverit gives an error like " Object reference not set to an instance of an object.Exception Details: System.NullReferenceException: Object reference not set to an instance of an object._isRefresh = _refreshState == (bool) Session["__ISREFRESH"]; "
View 1 Replies
Nov 3, 2010
global.asax:-I have defined a struct (my_struct)-I add a List of structs (List<my_struct>) to Application["MyList"] In default.aspx:-I have defined the exact struct (my_struct) and want to cast the Application["MyList"] object to the List of structs.
example: x = (List<my_struct>)Application["MyList"];
I receive this error "Unable to cast object of type 'System.Collections.Generic.List`1ASP.global_asax+my_struct]' to type 'System.Collections.Generic.List`1[_Default+my_struct]'
View 1 Replies
Nov 9, 2010
[Code]....
View 3 Replies
Aug 28, 2010
I have written a property globally on page load i am storing setting some value into that property but on button click i am not able to retrieve the data. Is there any alternate way to save the data other than viewstate or sessionstate. Ex:
Partial Class _Default Inherits System.Web.UI.Page Private s As String Public Property Test() As String Get Return s End Get Set(ByVal value As String) s = value End Set End Property Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack Then s = "Test" End If End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click s = "Champ" End Sub Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click MsgBox(s.ToString()) End Sub End Class
View 11 Replies
Oct 20, 2010
Using the properties as defined in a class, how about can I put them into the ParamArray parameters argument of my function. The code as follows:
Public Class MyObject
Public Property Prop1 as string
Public Property Prop2 as integer
Public Property Prop3 as Boolean
Public Sub AddNewMyObject
MsSQL_ExecuteNonQuery("StoredProc_AddNewMyObject", ________________?)
End Sub
End Class
Protected Function MsSQL_ExecuteNonQuery(ByVal storedProc as string, ByVal ParamArray parameters as object())
'Some Code here.
End Function
View 2 Replies
Mar 31, 2011
I have created a user control with a property named CurrentPage. When a link button is clicked it runs PostbackToPage() and passes a command argument in which then sets the CurrentPage property with this new value. On the page which uses the user control I am trying to display the updated CurrentPage property after a postback. When I click the link button to cause the postback the CurrentPage is the default value. However when I click it again it works as expected. So it seems to only work after 2 postbacks. How can I get this to work after the first postback?
User control code behind:
[Code]....
User control design:
[Code]....
Page which uses user control:
[Code]....
View 5 Replies
Oct 29, 2010
Actaully i am careted one webservice name:service1,created one more class name: service2 this poperty class for webservice,My question is
1.How to access that property class in client side?
2.It's possible to create Layer archt. Inside the webservice?
View 4 Replies
Sep 9, 2010
I have two class
e.g
List Class
Value Class
And List Class is inherits from Value Class
e.g
Public Class List
Inherits List(of Value)
Question:
I have Master Page and in master page i have user control, where i want to keep adding value in mention list class and i want to use this list class values in other pages.
How can i adding value in list class without intializing with new??
View 3 Replies
Sep 29, 2010
I have an object to hold some specific state information in my web application - I pass it back & forward between pages by making it a property of a basepage which works fine, but I lose it on postback.
Is there any way to persist this property without manually adding & reading it again from viewstate?
View 3 Replies
Apr 10, 2010
I'm using session to store C# object but my session is expiring regularly.
I've given 540 minutes for session timeout. ( <sessionState mode="InProc" timeout="540"/>)
Now I want to use cookie instead of session to remove this timeout problem.
code below:
[code].....
View 17 Replies
Feb 18, 2011
I have code :
[Code]....
Is it right?
View 4 Replies
Apr 1, 2010
I had an xml-serialization which worked fine, but as I have just knew it doesn't work in Opera browser. I think, it's security rules don't allow to write to cookies xml-content.What can I do? Can I use binary serialization or something else?
View 2 Replies
Oct 26, 2010
Anyway, I currently have a ajax based progressbar, which works like this: my long-task stores progress in session. Async callback retrieves progress from session, progressbar is updated. Everybody is happy... not! This only works when the "main loop" of the time-consuming task runs in either codebehind or a class with httpcontext. But all my businnes objects cannot do such thing. So, the next natural spet would be to say "move it to a static class" ProgressHelper or something, but since static classes are shared across all appDomain, I would bump into concurrence problems. So, can i have say a "static list progress" say progress["session1_progress"], progress["session2_progress"], progress["sessionN_progress"]? I cannot really see a way to update progress from inside a task in a business object, which i might want to use also in other plattforms like a desktop app?
View 7 Replies
Sep 24, 2010
I am working with asp.net mvc and i am trying to get acces to a object that is in the cache.In the Application_Start() of Global.asax.cs i create and store an object in the cache like this:
Translator translator = new Translator();
HttpContext.Current.Cache.Insert("Translator", translator, null, System.Web.Caching.Cache.NoAbsoluteExpiration, System.Web.Caching.Cache.NoSlidingExpiration);
Translator holds a dictionary with translations.Now i want acces to this object from the cache to use functions and get values from the dictionary.I know i can acces it like this HttpContext.Current.Cache.Get("Translator") or Cache.Get("Translator") in the views But how can i use the functions of the object ? The meaning of the cache is to have a object that is accesable througout the webapp right ?
Do i have to make an object and asses the value of the Cache.Get("Translator") to it, so i can use the functions or is there another solution?
View 3 Replies