473,757 Members | 3,768 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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\Seria lizedClassData" ,
FileMode.Create );

// Create a BinaryFormatter object to perform the serialization
var bf = new BinaryFormatter ();
var dt1 = DateTime.Now;
var dt2 = DateTime.Now;
DateTime.TryPar se(ddlStart.Sel ectedValue, out dt1);
DateTime.TryPar se(ddlEnd.Selec tedValue, out dt2);

var AAIL = AAISummaryManag er.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 3155
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\Seria lizedClassData" ,
FileMode.Create );

// Create a BinaryFormatter object to perform the serialization
var bf = new BinaryFormatter ();
var dt1 = DateTime.Now;
var dt2 = DateTime.Now;
DateTime.TryPar se(ddlStart.Sel ectedValue, out dt1);
DateTime.TryPar se(ddlEnd.Selec tedValue, out dt2);

var AAIL = AAISummaryManag er.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\Seria lizedClassData" ,
FileMode.Create );

// Create a BinaryFormatter object to perform the serialization
var bf = new BinaryFormatter ();
var dt1 = DateTime.Now;
var dt2 = DateTime.Now;
DateTime.TryPar se(ddlStart.Sel ectedValue, out dt1);
DateTime.TryPar se(ddlEnd.Selec tedValue, out dt2);

var AAIL = AAISummaryManag er.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
5679
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 Washington D.C. area VB.NET developer for WinForms + WebServices position.
1
1236
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 properties saved in viewstate. What I need is: if a user control is not visible it shouldn't save it's viewstate or the viewstate of the user controls and server controls it contains and so on recursively. Im guessing I should override the SaveViewState...
2
3255
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 there is a button. Somehow the submit seems to initialize the variable again, rathen then keeping its previous state/value. The variable has to be public to all methods in the class. codebehind:
10
2360
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 component reads data from a binary file. I'm guess i'm wondering which of the two options would be best. 1) read data from the binary files (~27 mb or so) 2) or query a sql DB with the same info.
0
1075
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 class. and Page.ViewState is not serializable. Is there any way to get serialized string of ViewState without overriding SavePageStateToPersistenceMedium ?
3
3147
by: MMiGG | last post by:
Hi Our project need parse JAVA serialized object string in C, has any library? Thanx
0
1407
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 regular pages -- just not in a control. Is the main page's viewstate interfering with the control's viewstate? Thanks,
1
3043
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 in any phase (any step) and to be able to continue later. My idea was to create several pages as steps (no, wizard control is not suitable for several reasons) and to allow users to save any step to the database, that is, a ViewState of the...
4
2645
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 flawed. The app config file appears to be updated with values while the application is running but when the application closes, the file seems to get restored to a pristine state and the accumulated user options and application settings are...
0
9297
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10069
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9904
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9735
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5324
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3828
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3395
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2697
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.