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 ?
virafhAsked:
Who is Participating?
 
virafhAuthor Commented:
buddy, you did not understand what i want, let me explain again, please see the html codes, when user enter his name and age and then click on submit button, i want the divMain with all its textbox values not actual textbox


<div runat="server" id="dvMain">
        <table width="100%">
            <tr>
                <td>Name:
                </td>
                <td><asp:TextBox runat="server" ID="txtName"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>Age:
                </td>
                <td><asp:TextBox runat="server" ID="txtAge"></asp:TextBox>
                </td>
            </tr>
        </table>
    </div>
    <div><asp:Button runat="server" ID="btnSubmit" Text="Submit" /></div>

Open in new window

0
 
rajeeshmcaCommented:
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
0
 
princeatapiCommented:
Well try this .

 At some instance you may supposed to send the mail ( may be a Form what you mentioned ) just put all your from contents inside a div

store the innerHTML contents to a hidden field

hidField.Value = MyDiv.innerHTML ; this would bring whats presently in your form ( Just What You See Is What You Get )

If you require more formatting then apply it in the HiddenField Content and Export to mail .
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
virafhAuthor Commented:
its giving me error

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

0
 
princeatapiCommented:
may  i have your Javascript code ??
0
 
princeatapiCommented:


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;
0
 
princeatapiCommented:
Just assign the value to the a HiddenField and access the hidden field from server
as myHidden.Value
0
 
virafhAuthor Commented:
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

0
 
princeatapiCommented:
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>
0
 
princeatapiCommented:
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());
    }
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.