Postback - Store Object Class In Viewstate (or Other Ideas)

Sep 8, 2010

I've build a class like this:

[code]....

The values of this class are set at postback by clicking a radiobutton list. Problem however is I don't know how to save this values across multiple postbacks. I thought of using viewstate but I'm not quite sure how to do it with this class.

Maybe I'm missing some important thing here.

Hope someone can point me in the right direction.

View 4 Replies


Similar Messages:

Configuration :: Serialize An Object To Store In ViewState?

Aug 6, 2010

Why to Serialize an object to store in ViewState?

View 1 Replies

C# - How To Store An Array In A ViewState Error / Unable To Cast Object

Feb 6, 2011

My code is:

[code]....

When I run the program, an error occurs:

Unable to cast object of type 'System.Collections.Generic.List`1[System.Int32]' to type System.Int32[]'.

Why does this error occur?

View 2 Replies

C# - Sharing An Object Between Methods In Same Class (with Postback)?

Nov 19, 2010

I have a user control with a number of methods. I also have a dataset object that I'm filling in one method, but I also need to access that same dataset (and the data in it) in another.

I am filling the dataset from some xml that I get from a webservice when someone clicks on a button. The data from the dataset is then bound to a listbox control. When someone selects an item in the list control (I have autopostback set to true on it) it then fires off another method and it's this method where I need to access the data in the dataset, but when I check the immediate window it's telling me that the dataset is set to null.

Where am I going wrong?

[code]....

View 4 Replies

Web Forms :: Class Object Becomes NULL After PostBack

Feb 13, 2014

I have a asp.net page titled EstMaterials.aspx with a gridview that fills from a SQL table based on a parameter passed to it.  The code for calling the form is below.

<asp:UpdatePanel ID="upAddMaterials" runat="server">
<ContentTemplate>
<div id="AddMaterials" style="text-align:center">
<asp:Button ID="btnDecoy" runat="server" Text="Decoy" style="display:none" />
<asp:LinkButton ID="lbAddMaterials" runat="server" Text="Add Materials"></asp:LinkButton>

[code]....

 I have an a button field set as a link in a gridview.  When the user clicks on the link it should open the "EstMaterials.aspx" page with a gridview listing the materials required for this job.  If I do not have a parameter i.e, ScheduleWeek.oJob.JobSeqNbr, the gridview fills fine.  However, with the parameter listed the gridview does not fill.  It appears the form opens without ever looking at the parameter being passed.The page load event is below.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
If Not IsNothing(ScheduleWeek.oJob) Then
Dim tbl As New DataTable

[code]....

View 1 Replies

State Management :: How To Persist A Class Object When Page PostBack

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

C# - Store Class Instance (helper Class) In Cache?

Jun 30, 2010

I have a class instance which is created by using Activator.CreateInstance() method. That class instance contains helper methods which are frequently used throughout the application. In order to avoid creating the instance multiple times, I'm just thinking about implementing an appropriate caching mechanism. The following consideration should be taken into account:

1) I can't use static class and methods.
2) There are around 6 instances (1 instance per class) per App Domain.

View 4 Replies

Javascript - How To Store Value To ViewState

Jan 26, 2011

I can tried save some data to ViewState, but i get this Error:

Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Error serializing value 'HeRMeSSAAS.BussinesProcess.BussinesServices.CandidateService' of type 'HeRMeSSAAS.BussinesProcess.BussinesServices.CandidateService.'
Code:

private IActionService ActionService
{
get [code]...
How i can store value to ViewState?

View 2 Replies

C# - Store A Queue In Viewstate?

Apr 29, 2010

EDIT: ViewState does not change when browser is refreshed, so even if you write to viewstate it will not save the data. i am trying to store a Queue in a viewstate (to track postbacks and refreshes to stop a form from resubmitting). The Queue is only saving with a count of 1 (the first item that is added to it) no matter how many items i add.

// New Queue of strings
private Queue<string> sTemp;
private Queue<string> p_tempQue
{
set
{
ViewState["sTemp"] = value;
}
get
{
return (Queue<string>)ViewState["sTemp"];
}
}
//BasePage constructor
public BasePage()
{
//create a Queue of string
//sTemp = new Queue<string>();
this.Load += new EventHandler(this.Page_Load);
this.Init += new EventHandler(this.Page_Init);
}
//In the 'page_Init' event we have created a simple hidden field by name 'hdnGuid' which is attached to the page on the first hit itself.
protected void Page_Init(object sender, EventArgs e)
{
//initializing the hidden field
//create a hidden field with a ID
HiddenField hdnGuid = new HiddenField();
hdnGuid.ID = "hdnGuid";
//if it is the first time the page is loaded, create a new guid and assign it as the hidden field value
if (!Page.IsPostBack)
hdnGuid.Value = Guid.NewGuid().ToString();
//add the hidden field to the page
Page.Form.Controls.Add(hdnGuid);
}
//In the 'page_Load' event we check if the hidden field value is same as the old value. In case the value is not same that means it's a 'postback'
//and if the value is same then its 'refresh'. As per situation we set the 'httpContent.Items["Refresh"]' value.
protected void Page_Load(object sender, EventArgs e)
{
if(p_tempQue != null)
sTemp = p_tempQue;
else
sTemp = new Queue<string>();
//The hdnGuid will be set the first time page is loaded, else the hdnGuid
//will be set after each time the form is submitted using javascript.
//assign the hidden field currently on the page for manipulation
HiddenField h1 = (HiddenField)(Page.Form.FindControl("hdnGuid"));
//create an instance of the GuidClass
GuidClass currentGuid = new GuidClass();
//set the GuidClass Guid property to the value of the hidden field
currentGuid.Guid = h1.Value;
//check to see if the Queue of strings contains the string which is the current Guid property of the GuidClass
//if the are equal, then the page was refreshed
if (sTemp.Contains<string>(currentGuid.Guid))
{
//adds item as key/value pair to share data between an System.Web.IHttpModule interface and an System.Web.IHttpHandler interface during an HTTP request.
System.Web.HttpContext.Current.Items.Add("IsRefresh", true);
}
//if they are not requal, the page is not refreshed
else
{
//if the current Guid property in the GuidClass is not null or not an empty string
//add the new Guid to the Queue
if (!(currentGuid.Guid.Equals(null) || currentGuid.Guid.Equals("")))
sTemp.Enqueue(currentGuid.Guid);
System.Web.HttpContext.Current.Items.Add("IsRefresh", false);
}
p_tempQue = sTemp;
}

View 3 Replies

How To Store A Byte[] List In Viewstate

Feb 6, 2011

I want to store some byte[] to ViewState. For example I want to store a list of FileBytes. How can I do it?

View 1 Replies

Store Viewstate Other Than In Hidden Field

Jan 30, 2010

can we store viewstate other than in hidden field in asp.net

View 2 Replies

State Management :: How To Store List In ViewState

May 27, 2010

I want to store List<Class> object to ViewState, when i try to do this than its giving me error to make class serialize,but my class is partial class so didn't get serialize keyword on class how can i store List object to viewstate.

View 4 Replies

C# - Store Viewstate In The Session Rather Than Bulking Up The HTML

Jan 7, 2011

I'm trying to get asp.net to store viewstate in the session rather than bulking up the html.

Now i've read that asp.net comes with the SessionPageStatePersister which can be used instead of the default HiddenFieldPageStatePersister to do this. I was wondering how i go about dropping it in?

This is what i've got so far:

I think i need to create a PageAdapter that returns a SessionPageStatePersister from its GetStatePersister method, and somehow get the page to use this pageadapter. But Page.PageAdapter only has a getter, so i'm not sure how you set it.

See the 'remarks' heading here: [URL]

View 3 Replies

State Management :: How To Store IQueryable Value In ViewState

Jan 3, 2011

i want to store IQueryable value to ViewState. my code is as below:

Private
Property _Query()
As IQueryable
Get
Return
CType(ViewState("_Query"), IQueryable)
End
Get
Set(ByVal value
As IQueryable)
ViewState("_Query") = value
End
Set

but when i run my page i get following error:

Type 'System.Data.Linq.DataQuery`1[[DynamicQueries.VW_EmployeeProfile_Filter, DynamicQueries, ersion=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' in Assembly 'System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable

what should i do to get rid of this error. previously i was doing like this:

Private Shared _Query As IQueryable

but problem is that in Multi users environament, Shared variable is making problem, that is why i want to store it in ViewState.

View 4 Replies

Web Forms :: How To Store Multi Dimensional Array To Viewstate?

Oct 8, 2010

How do you store multi-dimensional array to viewstate? Here's what I did:
public bool[,,] regsettings = new bool[7,5,4];
bool[,,] regsettings = (bool[,,])ViewState["regsettings"]; // this line works!
regsettings[i,j,tab] = (bool)ViewState["regsettings"]; // this line no working?! The error is: Object reference not set to an instance of an object. The letters i,j, tab are just variables in the loop. They are there. I also tried: (bool[,,,]) as a cast and it is a no-go either.?

View 1 Replies

To Store Credit Card And Pricing Information In ViewState Even Over Ssl?

Jul 7, 2010

The Title pretty much says it all but to clarify more I have a page with private properties that are storing a credit card object and a shopping cart object in viewstate so I can maintain a reference to them across postbacks. BTW the page involved will be using ssl. Is this safe?

View 6 Replies

Where Should Store A Data Table ViewState/ Session/ Cache

Apr 21, 2010

I have a DataTable with about 10,000 rows in it.

I would like to store this data once for aspx page. When the user selects different options in the page, data is further selected from the already stored DataTable.

I tried using the ViewState, but as soon as the data grows beyond 100 rows, performance degrades.

View 1 Replies

State Management :: Store Viewstate Values In Another Methods?

Apr 14, 2010

In my website the page viewstate values in hidden are very large.So i wish to store this values into another methods(session,files etc).so please advice me to some methods..

View 3 Replies

State Management :: Common Function To Retrieve / Store To Viewstate?

May 15, 2010

I have a public property that I use to store a GUID in the viewState:

Property myGUID()
As
Guid
Get
Return
CType(Me.ViewState("myGUID"),
Guid)
End
Get
Set(ByVal
value As
Guid)
Me.ViewState("myGUID")
= value
End
Set
End
Property

I include this code on many pages in my website...is there any way to migrate this to a common code file, so I don't have to repeat it on each page? If I try to add it to a class file, the "Me" part of course is out of scope.

View 4 Replies

State Management :: Store Viewstate In Session ( Framework 3.5, VS 2008 )?

Nov 9, 2010

I need to store viewstate in session to optimize my page performance on postback.

I am developing ASP.Net Website, using Visual Studio 2008.

I created a class named "BasePage" under "App_Code".

[Code]....

Now, I know if I inherit this class in all of my pages, that will work but I am looking to do this through Config file.

Is there any way that I can write something in Config file to use this class for all the pages?

so that if I want to remove, I can simply remove from config file and I do not need to compile my whole project again.

View 4 Replies

C# - How To Convert Json Object To Custom Class Object In Web Service

Aug 30, 2010

I've scenario where I want to insert data into database without post back. there are around 12 to 13 fields which i need to insert. I'm passing DTO from the client side which is actually Json object. Now the problem which i'm facing is how to convert that Json object which i got in webservice to the "class" (in my case class name is User) object.

[Code]....

In the above case AddNewUser method takes the object of User class. But i'm getting casting error. So how do I convert Json object to the "User" class object?

View 3 Replies

How To Optimize Class For Viewstate

May 6, 2010

If I have an object I need to store in viewstate, what kinds of things can I do to optimize the size it takes to store the object? Obviously storing the least amount of data will take less space, but aside from that, are there ways to architect the class, properties, attrbutes etc, that will effect how large the serialized output is?

View 3 Replies

Security :: Ideas On Structuring Administration Section

Jan 28, 2010

I need some fresh input on how to structure a control panel that I'm building. Here's a little background:

The purpose of the system is to allow the submission of online forms. The forms are stored and processed in a database. Currently there are 3 departments that each have their own set of forms, and each department processes their forms a little differently. The staff should log in and process forms for their respective department (so each department only sees their submissions).

Almost all forms go through a workflow of sorts: 'new submission'-->'in progress'-->'completed', although this may vary.

Right now I've got it mapped out to have a page for each dept. that displays the new submissions, completed forms, etc. (new.aspx, inProgress.aspx, completed.aspx). Here's the question--should I have only one completed.aspx page and use it for all departments (hiding and showing forms based on the employee/department that is logged in), or should I set up three different control panels with three different completed.aspx pages--one for each department?

View 2 Replies

How To See If Viewstate Changed When Postback

May 12, 2010

well what i want to find out is how can i figure out if some change occurd in page when postback , i mean when the first state of the page hahe any changes after postback . I thought maybe somehow to compare viewstaes but i can not find out how can i do that.

View 13 Replies

Viewstate Getting Bigger After Postback?

Apr 8, 2010

I have a grid with rows of data, but the page will fail have several postback. I check it with fiddler and find that view state expands 2-3 times after each post back.

The thing I did to trigger the post back is searching and sorting. I am not sure how it happens.

View 2 Replies







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