0

I'm trying to access some page HTML to use for an email in a Button_Click event.

I cannot set this content easily anywhere else at runtime (Such as in a TAG).

So I'm wondering if I can use JQuery to set a variable to .innerHtml(), and pass that in the button click. How would I go about doing this?

Community
  • 1
  • 1
Wesley
  • 5,169
  • 8
  • 38
  • 62

2 Answers2

0

To add a hidden field to a form: fill its value using javascript/jQuery and submit the form via a Button_Click event.

Andy Hayden
  • 328,850
  • 93
  • 598
  • 514
Summerson
  • 11
  • 1
0

Something like this...

<div id="myDiv">
    some content...
</div>
<asp:HiddenField ID="hdnHtml" ClientIDMode="Static" runat="server" />
<script type="text/javascript">
    $(function () {
        $('#hdnHtml').val($('#myDiv').html());
    });
</script>
CoderMarkus
  • 1,108
  • 1
  • 9
  • 24