Link to home
Start Free TrialLog in
Avatar of virafh
virafh

asked on

mail page with content

Dear Friends,

i know how to send email using codes with html format.

my requirement:
i have a form with text box, dropdown, radion buttons etc.

now i want to send the form as it is with the selected and inserted values in the form.


how can i ?
Avatar of rajeeshmca
rajeeshmca
Flag of India image

Instead of sending the whole form, u can send the Link for that form with querystrings.

If at all u would like to send the complete form, you will have to frame the html such that it is by default selected.

Otherwise frame the selected items to a text and send it
SOLUTION
Avatar of princeatapi
princeatapi
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of virafh
virafh

ASKER

its giving me error

Cannot get inner content of dv because the contents are not literal.

may  i have your Javascript code ??


document.getElementById('MyDiv') will give you only the element itself. If you want the contents of the element, you'll need to use innerHTML or some other DOM-based technique to retrieve the contents of that element.

try like this
var MailContent = document.getElementById("MyDiv").innerHTML;
Just assign the value to the a HiddenField and access the hidden field from server
as myHidden.Value
Avatar of virafh

ASKER

please see the attached test code
<body>
    <form id="form1" runat="server">
    <div runat="server" id="dv">
    <asp:TextBox runat="server" ID="txt"></asp:TextBox>
    </div>
    <p>
        <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
    </p>
    </form>
</body>



    protected void Button1_Click(object sender, EventArgs e)
    {
        string str = dv.InnerHtml;
        Response.Write(str);
    }

Open in new window

you can get like this

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>

    <script type="Text/javascript">
   function Change()
   {
       document.getElementById("MyMailContent").value =  document.getElementById("dv").innerHTML;
   }
    </script>

</head>
<body>
    <form id="form1" runat="server">
        &nbsp;
       
        <div runat="server" id="dv">
            <asp:TextBox runat="server" ID="txt"></asp:TextBox>
        </div>
        <asp:Button ID ="Test" runat ="server" Text ="ClickMe" />
        <asp:HiddenField ID ="MyMailContent" runat="server" />
    </form>
</body>
</html>
Please find the Code Behind

protected void Page_Load(object sender, EventArgs e)
    {
        Test.Attributes.Add("OnClick", "javascript:return Change()");

        Response.Write(MyMailContent.Value.ToString());
    }
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial