ASP. NET Status Management 3 (hidden domain hiddenfield)

Source: Internet
Author: User

 

ASP. NET allows you to store information in the hiddenfield control, which is displayed as a standard HTML hidden field.
Hidden domains are not displayed as visible in the browser, but you can set their properties just like standard controls.
When you submit a page to the server, the content of the hidden field will be sent along with the values of other controls in the HTTP form set.
The hidden domain can be used as a repository to store any page-specific information that you want to directly store on the page.

Security considerations
Malicious users can easily view and modify the content of hidden domains. Do not store any sensitive information or safeguard applications in the hidden domainProgramThe correct running information.

The hiddenfield control stores only one variable in its value attribute and must be explicitly added to the page.
To use hidden domain values during page processing, you must use the http post command to submit the corresponding page. If you use a hidden domain and process the page in response to a link or http get command, the hidden domain is unavailable.

The hiddenfield control is used to store a value, which must be kept during each sending process to the server. It is rendered as the <input type = "hidden"/> element.
Generally, the status of a web form page is maintained by view status, session status, and cookie. However, if these methods are disabled or unavailable, you can use the hiddenfield control to store status values.

To specify the value of the hiddenfield control, use the value attribute.

During each sending process to the server, when the value of the hiddenfield control is changed, the valuechanged event is triggered.

<HTML xmlns ="Http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> No title page </title>

<SCRIPT type = "text/JavaScript">
Function pageload ()
{

// Set the value of the hiddenfield control with
// Value from the textbox.
Form1.valuehiddenfield. value = form1.valuetextbox. value;

}

</SCRIPT>

</Head>
<Body>
<Form ID = "form1" runat = "server">
<Div>
<Asp: textbox id = "valuetextbox" runat = "server"/>
<Br/>
<Input type = "Submit" name = "submitbutton" value = "Submit" onclick = "pageload ()"/>
<Br/>
<Asp: Label id = "message" runat = "server"/>
<Asp: hiddenfield id = "valuehiddenfield" runat = "server" onvaluechanged = "valuehiddenfield_valuechanged"/>
</Div>
</Form>
</Body>
</Html>

 

 

 

 

Summary

You can store page-specific information in the hidden domain on the page as a way to maintain the page status.
If you use a hidden domain, it is best to store only a small amount of frequently changed data on the client.

Note:
If you want to use a hidden domain, you must use the http post method to submit a page to the server, instead of the http get method to request the page through the page url.
 

Advantages of using hidden Domains
1. No server resources are required: Hide the domain to store and read on the page.
2. Extensive support: almost all browsers and client devices support forms with hidden fields.
3. Easy Implementation: hidden fields are standard HTML controls and do not require complex programming logic.

Disadvantages of using hidden Domains
1. potential security risks
The hidden domain can be tampered. If you directly view the page output source, you can see information in the hidden domain, which leads to potential security issues.
You can manually encrypt and decrypt the content of the hidden domain, but this requires additional encoding and overhead. If you are concerned about security, consider using the server-based status mechanism so that sensitive information is not sent to the client.
2. Simple Storage Structure
Hidden domains do not support complex data types.
The hidden domain only provides one string value field for storing information.
To store multiple values, separate strings andCode. You can manually serialize complex data types to hidden domains and deserialize hidden domains to complex data types. However, this requires additional code.
If you need to store complex data types on the client, consider using view status. The view status has built-in serialization and stores data in a hidden domain.
3. Performance Considerations
Because the hidden domain is stored on the page itself, if a large value is stored, the speed of page display and page sending may be slowed down.
4. Storage restrictions
If the amount of data in the hidden domain is too large, some proxies and firewalls will block access to pages containing the data. Because the maximum number varies with the firewall and proxy used, large hidden domains may encounter unexpected problems.
If you need to store a large number of data items, consider one of the following operations:
(1) place each item in a separate hidden domain.
(2) Use the view status and open the view status blocks. This will automatically split the data into multiple hidden domains.
(3) do not store data on the client and keep the data on the server. The more data you send to the client, the slower the response time of your application, because the browser needs to download or send more data.
 

 

SQL server2005 Transact-SQL new weapon learning Summary-Summary
Ms SQL database backup and recovery stored procedures (enhanced)
SQL Server Distributed Query essay (sp_addmediaserver) and remote login ing (sp_addmediasrvlogin) use small summary)
WAP development data station (latest update)
Custom Format String (implementation of the three interfaces of iformattable, iformatprovider, and icustomformatter)
Asynchronous programming of mcad learning notes (asynccallback delegation, iasyncresult interface, begininvoke method, and endinvoke method)
Mcad learning notes: Calling class methods through reflection, attention, fields, indexers (2 methods)
Serialization of mcad learning notes (binary and soap serialization)
Delegated re-understanding of mcad learning notes (discussion of Delegate constructor, begininvoke, endinvoke, and invoke4 methods)
Winform development, form display, and form value passing knowledge
Microsoft Windows service using mcad Study Notes
Copy all the objects and files under a certain category to the target category (number of objects)
ASP. NET status management (Summary)

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.