Dynamic Input Form implementation)

Source: Internet
Author: User
Demand generation: the company requires the system to implement global control of product prices, and dynamically generate input forms in the price management module, the effect is like Excel For details, see:



"1" controls the generation of Form "2" within the range of the red box (due to a number of products with different product lines)

"3" controls the generation of "4" forms within the range of the blue box (different pricing policies vary for different products within the same period of time)

Solution:

In "2", some forms except "4" TakeWebWidget

In "4", the form is takenHtmlCodeSimulation.

After exploration, we found that Web Control, as long as the control ID The status information can be retained after refresh ( Aspx Of Page Join Enableviewstate = true ), So the problem to be solved now is to have a hidden control. Itemcount How many "2" records are generated, Itemcount It is a non-dynamic control pulled in, And the status information can be retained. Therefore, the action "1" is actually Itemcount And then Page_load When the cycle generates "2", remember that all controls should be regular (Control Type _ Control meaning _ Line number ). ID .

"3" for "4" needs to be generated Hmtl Code to simulate it. It was originally intended to be used Web The final result of the research is that the dynamic control in the dynamic control cannot retain the status information, so the status information and the form can only be simulated here. So we need to drag in a control. Pricevalue To save the price information. The storage format is "row number 1, Price 1, date 1 ". | Row number 2, price 2, date 2 ......", Two operations are required in the background. One is to spell out strings in this format, and the other is to simulate the price Input form based on the database price information. Note that any change to the price form should trigger a client script, re-traverse all the price forms, and then rewrite them. Pricevalue In this way, the price information can be saved instantly, and only when the page is refreshed is lost.

Although the above is simple, there are many details to consider during actual development. For example, a simple deletion may disrupt the law and special processing is required, in addition, the image selection information needs to be retained by the user (the file selection box will disappear after a click on the file selection information )...... At last, the background code of this page was written into nearly three thousand lines, which is really a failure, but the user wanted to achieve it, but the user was satisfied ......

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.