简体   繁体   中英

save client control (HTML) server side

We have HTML templates generated from an old dos database, displaying these in .net is fine, what I need to be able to do is capture the said templates after input fields have been changed and save the file back server side.

I have got this working with some jQuery but as I load the template into a asp:literal control on the page it only saves back what was sent. I need to be able to post the whole section including the HTML back to the server. I cannot define each input field.

The reason behind this is so the page can be generic and load and save whatever the templates have as input fields.

Any clever idea or better way of doing this would be of help

I have gone to basics

$(document).ready(function () {

    $("#save").click(function () {
        alert("HTML: " + $("#MyHTML").html());
    });
});

when ever I click the save button it will only show the HTML that was delivered.. I want to collect the HTML including input fields that have been modified by the client. Like a normal POST but the template as no inteligence to send the data back to the server..

another point is that if I make the change to the page by changing the value="blah blah" in firebug and click the save button I get the change but the screen then changes the field back to the original data..... Am I missing somthing here??

so am assuming these are the steps that you are following currently

1. Reading db for templates content
2. generating equivalent html for these templates and adding it to the dom(a html page)
3. Adding some data to the generated input controls
4. Get Entire HTML again and Save to Database

I am assuming you are able to successfully do first 3 steps now if you want to capture entire content just do this:

firstly, populate your template inside some container, say any or

now simply do this:

<script>
$(document).ready(function(){
  var templateModifiedData= $('#containerId').html();
   makeAjaxRequest(templateModifiedData); //send to server method to save in db
});
</script>

as simple as that. important is, how you populate your templates.

this should give you an idea though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM