Hi, all!

I've been trying to pass a javascript variable to an asp.net webapp through a hidden input field.
All according to post http://www.daniweb.com/techtalkforums/thread26184.html.

But something seems to be garbled.

Here's what parts of my aspx code looks like.

...
             var src = document.documentElement.outerHTML;
                   document.getElementById("pSource").Value = src;
               }
 </script>
</head>
<body>
<form runat="server">
      <input id="pSource" type="hidden" />
...

Somehow the line document.getElementById("pSource").Value = src; doesn't work.
I've tried with <input id="pSource" type="hidden" runat="server" /> as well.

The javascript code is in a window.onload function.
What I want to do is to have the content of the hidden field mailed as html from CodeBehind.

Any suggestions?

I solved it myself by expanding the coding Sathiya used in this thread: http://www.daniweb.com/techtalkforums/showthread.php?t=45854

My solution was to use the RenderControl method in the Page class.
This gives me the entire entity of the rendered page as a string, which can then be used as body in a html-mail.
And this can be done without any hidden variables and javascript code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.