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,381
  • 9
  • 42
  • 65

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
  • 359,921
  • 101
  • 625
  • 535
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,118
  • 1
  • 10
  • 24