Data loss after submitting dynamically created HTML controls and Solutions

Source: Internet
Author: User
Tags xslt

A B/S Project reports need to be drawn , Many reports have complicated headers. ,, In addition, many columns are dynamically created. , Use DataGrid Difficult to implement . I thought about it. , All reports are used XML + XSLT Dynamic Creation , Although XSLT Syntax is a little cumbersome , And there are many inherent shortcomings. , However, it seems very convenient. 40 Multiple reports , Approximate 2 It will be finished in half a day.

 

Some forms entered by users are also in the form of reports. They are all used for the moment. XML + XSLT Generate. Because of Input Controls are also dynamically created ( XSLT The server control is not created here, It is normal Html Control. Because Input Controls are common Html Control, and it is dynamically created, so every time the user submits it, it must be re-drawn, so it is clear that all the data entered and submitted by the user is lost! It seems that the user input data needs to be saved first. Read one by one Input And then recover them one by one, which is obviously abnormal and troublesome. Finally, I thought that I could directly "present the user input interface" on the client. Html CodeDirectly submit to the server. Submit the file and try again. Html Write the code back to the page.

 

1, Display Html Code" Put it in Inputdata Of <Span> Label.

2,In the submit button event Document. All. Item ('inputdata'). outerhtmlSave to a hidden field. What I use directly is_ DopostbackOf course, you can also write it yourself

Buttonsave. Attributes. Add ( " Onclick " , " _ Dopostback ('savedata', document. All. Item ('inputdata'). outerhtml) " );

 

3,This section can be obtained on the server side.HtmlCode

Literalinputdata. Text =   Null ;
If (Ispostback)
{
If (Request. Form. Get ( " _ Eventtarget " ) =   " Savedata " )
{
Literalinputdata. Text=Request. Form. Get ("_ Eventargument");
}
}

 

4, Just as you are 3 As shown in , In Web Add Literal Widget Literalinputdata, Directly obtain Html Just write the code back. .

5, Because the submitted data is Html Code , Default Web This type of data cannot be submitted on the page. Aspx Page <% @ Page Language = "C #" .. %> Add Validaterequest = false This sentence.

tested , OK ! if you do not submit data to the server, you can save the data in userdata medium, however, only IE6 supported. The above method is regarded as a small hack . Which of the following is a better solution?

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.