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?