473,386 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

save serialized binary to viewstate question

I can very simple save a serilized class to a server, but i don't know how to
serilize an object (here a business object) to a variable so that it can be
saved to viewstate or passed to another page?
here is my to disk version:

private void ser()
{
var fs = new FileStream(@"e:\websites\SerializedClassData",
FileMode.Create);

// Create a BinaryFormatter object to perform the serialization
var bf = new BinaryFormatter();
var dt1 = DateTime.Now;
var dt2 = DateTime.Now;
DateTime.TryParse(ddlStart.SelectedValue, out dt1);
DateTime.TryParse(ddlEnd.SelectedValue, out dt2);

var AAIL = AAISummaryManager.GetList(dt1, dt2);
// Use the BinaryFormatter object to serialize the data to the file
var bcls = new object();
bf.Serialize(fs, AAIL);

// Close the file
fs.Close();
}

now how do i serilize to a variable?

thanks!!
--
(i''ll be asking a lot of these, but I find C# totally way cooler than vb
and there''s no go''n back!!!)
thanks (as always)

kes
Nov 19 '08 #1
5 3141
as long as your object is serializable, you just add to viewstate. it
will be serialized when viewstate is converted to a hidden field.

your object should not be too large as view serializes to a memory
stream, then encrypted (which increases the size) then its converted to
base64 string which is 3 bytes for every 2 bytes input. all this data is
sent to the browser, then the browser has to send it back on a postback
-- bruce (sqlwork.com)

WebBuilder451 wrote:
I can very simple save a serilized class to a server, but i don't know how to
serilize an object (here a business object) to a variable so that it can be
saved to viewstate or passed to another page?
here is my to disk version:

private void ser()
{
var fs = new FileStream(@"e:\websites\SerializedClassData",
FileMode.Create);

// Create a BinaryFormatter object to perform the serialization
var bf = new BinaryFormatter();
var dt1 = DateTime.Now;
var dt2 = DateTime.Now;
DateTime.TryParse(ddlStart.SelectedValue, out dt1);
DateTime.TryParse(ddlEnd.SelectedValue, out dt2);

var AAIL = AAISummaryManager.GetList(dt1, dt2);
// Use the BinaryFormatter object to serialize the data to the file
var bcls = new object();
bf.Serialize(fs, AAIL);

// Close the file
fs.Close();
}

now how do i serilize to a variable?

thanks!!
Nov 20 '08 #2
Thanks for replying,
Maybe i should be asking: How do i serilize it and keep on the server. Then
be able to recall it during the post back. Instead of re hitting the db?
--
(i''ll be asking a lot of these, but I find C# totally way cooler than vb
and there''s no go''n back!!!)
thanks (as always)

kes
"bruce barker" wrote:
as long as your object is serializable, you just add to viewstate. it
will be serialized when viewstate is converted to a hidden field.

your object should not be too large as view serializes to a memory
stream, then encrypted (which increases the size) then its converted to
base64 string which is 3 bytes for every 2 bytes input. all this data is
sent to the browser, then the browser has to send it back on a postback
-- bruce (sqlwork.com)

WebBuilder451 wrote:
I can very simple save a serilized class to a server, but i don't know how to
serilize an object (here a business object) to a variable so that it can be
saved to viewstate or passed to another page?
here is my to disk version:

private void ser()
{
var fs = new FileStream(@"e:\websites\SerializedClassData",
FileMode.Create);

// Create a BinaryFormatter object to perform the serialization
var bf = new BinaryFormatter();
var dt1 = DateTime.Now;
var dt2 = DateTime.Now;
DateTime.TryParse(ddlStart.SelectedValue, out dt1);
DateTime.TryParse(ddlEnd.SelectedValue, out dt2);

var AAIL = AAISummaryManager.GetList(dt1, dt2);
// Use the BinaryFormatter object to serialize the data to the file
var bcls = new object();
bf.Serialize(fs, AAIL);

// Close the file
fs.Close();
}

now how do i serilize to a variable?

thanks!!
Nov 20 '08 #3
look at session, its for storing on the server. there is an inmemory or
sqlserver version. i always use the sqlserver version. you can also
serialize to a database, and store a key in a hidden field on the page.

-- bruce (sqlwork.com)
WebBuilder451 wrote:
Thanks for replying,
Maybe i should be asking: How do i serilize it and keep on the server. Then
be able to recall it during the post back. Instead of re hitting the db?
Nov 20 '08 #4
Very appreciated! I have no idea why i did not think of session. I normally
use the inmemory, but may go for the sql version.

Thanka!

"bruce barker" wrote:
look at session, its for storing on the server. there is an inmemory or
sqlserver version. i always use the sqlserver version. you can also
serialize to a database, and store a key in a hidden field on the page.

-- bruce (sqlwork.com)
WebBuilder451 wrote:
Thanks for replying,
Maybe i should be asking: How do i serilize it and keep on the server. Then
be able to recall it during the post back. Instead of re hitting the db?
Nov 20 '08 #5
that's the answer!!
--
(i''ll be asking a lot of these, but I find C# totally way cooler than vb
and there''s no go''n back!!!)
thanks (as always)

kes
"bruce barker" wrote:
look at session, its for storing on the server. there is an inmemory or
sqlserver version. i always use the sqlserver version. you can also
serialize to a database, and store a key in a hidden field on the page.

-- bruce (sqlwork.com)
WebBuilder451 wrote:
Thanks for replying,
Maybe i should be asking: How do i serilize it and keep on the server. Then
be able to recall it during the post back. Instead of re hitting the db?
Nov 20 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Samuel R. Neff | last post by:
Are there any tools available to view a file containing a binary serialized object in a friendly format? Something to list classes and data and such? Thanks, Sam B-Line is now hiring one...
1
by: Adrijan Josic | last post by:
I have a bunch of user controls that contain TextBoxes, Repeaters and so on. Some of the user controls even contain other user controls. The user controls also usually have some of their...
2
by: Leo Muller | last post by:
I tried to simplify my problem. What I want to do is to save a string in a variables, and everytime I click a button, the variable string gets a bit longer by adding the time to it: on the form...
10
by: Fabuloussites | last post by:
I'm considering deploying an application that will us an IP address locaiton database provided by Ip2location.com... http://www.ip2location.net/ip2location-dotnet-component.aspx their .net...
0
by: madani | last post by:
Hi, I need to get serialized string of Page ViewState in Constructor of my custom web control. I can not override SavePageStateToPersistenceMedium Method of page object because I'm in different...
3
by: MMiGG | last post by:
Hi Our project need parse JAVA serialized object string in C, has any library? Thanx
0
by: bminder | last post by:
I have a web user control that contains a serializable class. I persist this class in viewstate, but on postback, the viewstate is null. Is this behavior by design? This technique works fine on...
1
by: Irene | last post by:
Hello all! I'm creating a web site in ASP.NET (VB.NET). One of the requirements was to allow users to create orders going through several steps. A must have is to have an option to save the work...
4
by: Richard Lewis Haggard | last post by:
I have an application that can't use the registry to save various user options and application settings. My first thought was to simply use an application configuration file but this approach seems...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.