Differences between ViewState and Request. Form in ASP. NET view and string

Source: Internet
Author: User

I. View status is a method used by default by ASP. NET page framework to save the page and control value between the round-trip process. When the page is displayed in HTML format, the current status and value of the page to be retained during the sending-back process will be serialized as a Base64 encoded string and output to a hidden field in the view status. Implement custom Class to store page data, you can change the default behavior and store the view status to another location (such as SQL Server database ). The ViewState attribute is a dictionary containing key/value pairs (including view State data.

Web applications are stateless. Each time a webpage is requested from the server, a new instance of the webpage class is created. This usually means that all information associated with the page and its controls will be lost during each round-trip. For example, if a user inputs the information into a text box on an HTML webpage, the information is sent to the server but not to the client. ASP. NET page framework contains several state management functions, which can save the page and control value between the round-trip process to the Web server, one of which is the view status.

 

You can store the following types of objects in the view State:

  • String

  • Integer

  • Boolean Value

  • Array object

  • ArrayList object

  • Hash table

  • Custom type converter

The ViewState attribute is used as follows:

ViewState ["paramTable"] = (Hashtable) Session ["paramTable"];
ViewState. Add ("paramTable", (Hashtable) Session ["paramTable"]);

2. Obtain the DropDownList_sitebranch value in the drop-down box of the corresponding page in the CS file in the following methods:

SiteInfo. FZJGID = DropDownList_sitebranch.SelectedItem.Value.Trim ();
SiteInfo. FZJGID = Request. Form ["DropDownList_sitebranch"]. ToString ();
SiteInfo. FZJGID = Request ["DropDownList_sitebranch"]. ToString ();

The Request. Form is a collection of Form variables obtained by ASP. NET.

3. What is the difference between string and String in C?

String belongs to the C # type
String belongs to. NET Type
The two can be used in the same way. string is recommended.
All types in. NET are objects. The following table lists the types of. net c # VB. net il:

Net c # VB. net il value or reference
System. Boolean bool Value
System. Byte byte Byte unsigned int8 Value
System. Char char Value
System. DateTime-Date-Value
System. Decimal decimal Decimal-Value
System. Double double Double float64 Value
System. Int16 short Short int16 Value
System. Int32 int Integer int32 Value
System. Int64 long Long int64 Value
System. Object object Reference
System. SByte sbyte-int8 Value
System. Single float Single float32 Value
System. String string String Reference
System. UInt16 ushort-unsigned int16 Value
System. UInt32 uint-unsigned int32 Value
System. UInt64 ulong-unsigned int64 Value

From the table above, we can see that there are many similar types, not only string and String. Some do not have corresponding types. NET, for example, in C #, there is no date type, so we use in C. NET Date. this is also. NET.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.