ASP.Net Modal Not Displaying - c#

I have an ASP.Net form which on when a 'Submit' button is clicked it sends an email. This can take some time so i wanted to add a processing modal to the user knows that something is happening.
Now i have the modal displaying BUT it only displays once the email has either been sent of failed. I need this modal to be displayed as soon as the button is clicked and then close once the email action has either sent it or failed the send it.
If it fails my page do currently display an error message.
My HTML is
<div class="form-group">
<div class="col-xs-12">
<div class="pull-right">
<asp:LinkButton ID="pg3button" runat="server" OnClick="pg3button_Click" CssClass="btn btn-primary"><span aria-hidden="true" class="glyphicon glyphicon-ok"></span> Send & complete</asp:LinkButton>
</div>
</div>
</div>
<div class="modal fade" id="myModal" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<asp:UpdatePanel ID="upModal" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
<ContentTemplate>
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">
<asp:Label ID="lblModalTitle" runat="server" Text="">Processing</asp:Label>
</h4>
</div>
<div class="modal-body">
<asp:Label ID="lblModalBody" runat="server" Text="">
<p class="text-center">IMAGE GOES HERE</p>
</asp:Label>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
My code behind for my onclick for the submit button is
protected void pg3button_Click(object sender, EventArgs e)
{
try
{
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModal", "$('#myModal').modal();", true);
upModal.Update();
//Create the msg object to be sent
MailMessage msg = new MailMessage();
//Add your email address to the recipients
msg.To.Add("test#test.co.uk");
//Configure the address we are sending the mail from
MailAddress address = new MailAddress("test#test.co.uk");
msg.From = address;
//Append their name in the beginning of the subject
msg.Subject = "Enquiry";
msg.Body = Label1.Text + " " + Session["pg1input"].ToString()
+ Environment.NewLine.ToString() +
Label2.Text + " " + Session["pg1dd"].ToString()
+ Environment.NewLine.ToString() +
Label3.Text + " " + Session["pg2"].ToString();
//Configure an SmtpClient to send the mail.
SmtpClient client = new SmtpClient("smtp.live.com", 587);
client.EnableSsl = true; //only enable this if your provider requires it
//Setup credentials to login to our sender email address ("UserName", "Password")
NetworkCredential credentials = new NetworkCredential("test#test.co.uk", "Password10");
client.Credentials = credentials;
//MODAL CODE TO GO HERE
//Send the msg
client.Send(msg);
Response.Redirect("/Session/pg4.aspx");
}
catch
{
//If the message failed at some point, let the user know
lblResult.Text = "<div class=\"form-group\">" + "<div class=\"col-xs-12\">" + "There was a problem sending your request. Please try again." + "</div>" + "</div>" + "<div class=\"form-group\">" + "<div class=\"col-xs-12\">" + "If the error persists, please contact us." + "</div>" + "</div>";
}
}
I have also tried moving the follwing code outside my try
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModal", "$('#myModal').modal();", true);
upModal.Update();
I was think if there was a way i could call my button click then a function which has my email code in it but im new to ASP.Net and webforms
All i need is for the modal to be displayed the minute the button is clicked and removed once the page either redirects (if successful) or when my error is displayed

just use JavaScript instead of server side code for modal popup
when you click on button add OnClinetClick event and use a javascript function like
<asp:button id="pg3button" runat="server" OnClick="pg3button_Click" OnClientclick="ShowPopup();"></asp:button>
<script>
function ShowPopup()
{
$('#myModal').modal();
}
<script>
also remove update panel it is not useful in this context.

You are registering your script which shows modal,using the reigisterStartupScript function. Since it is a script it will get registered on the page only after the execution of your c# code. Try moving it to the aspx page itself on the onClientClick event of the button.
$( "#buttonId" ).click(function() {
$('#myModal').modal();
});

Related

Why my server side code is not firing on ASP.net Button click?

I don't understand why my server side is not executed.
Here is my code
ASP code
<div class="row" style="padding-top:20px;">
<div class="col-lg-4">
<input id="btnSave" type="button" class="btn btn-info" value="Save" />
<input id="btnLoad" type="button" class="btn btn-info" value="Load" />
<%-- SAVE DIALOG --%>
<div id="saveDialog" title="Basic dialog">
<div class="row">
<div class="col-lg-4">
<asp:Label ID="lblFileName" CssClass="control-label" runat="server" Text="File Name"></asp:Label>
</div>
<div class="col-lg-6">
<asp:TextBox ID="txtFileName" CssClass="form-control" runat="server"></asp:TextBox>
</div>
</div>
<div class="row">
<div class="col-lg-12" style="text-align:center;">
<asp:Label ID="lblSaveErrorMsg" runat="server" Text="" ForeColor="Red"></asp:Label>
</div>
</div>
<div class="row" style="padding-top:10px;">
<div class="col-lg-12" style="text-align:center;">
<asp:Button ID="btnSaveFile" runat="server" Text="Save" OnClick="btnSaveFile_Click"/>
</div>
</div>
</div>
</div>
Server Side Code
protected void btnSaveFile_Click(object sender, EventArgs e)
{
string cs = ConfigurationManager.ConnectionStrings["xxx"].ConnectionString;
using (SqlConnection con = new SqlConnection(cs))
{
byte[] byteArray = Encoding.UTF8.GetBytes(ASPxPivotGrid1.SaveLayoutToString());
MemoryStream stream = new MemoryStream(byteArray);
DateTime currentDate = DateTime.Now;
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "INSERT INTO ReportSave(UserID,ReportName,UserFileName,ReportData,Time,ReportFilter)VALUES(#UserID,#ReportName,#UserFileName,#ReportData,#Time,#ReportFilter);";
cmd.Parameters.AddWithValue("#UserID", UserID);
cmd.Parameters.AddWithValue("#ReportName", ReportName);
cmd.Parameters.AddWithValue("#UserFileName", txtFileName.Text);
cmd.Parameters.AddWithValue("#ReportData", stream);
cmd.Parameters.AddWithValue("#Time", currentDate);
cmd.Parameters.AddWithValue("#ReportFilter", txtFilterRecord.Text);
con.Open();
cmd.ExecuteNonQuery();
//string message = "Your details have been saved successfully.";
//string script = "window.onload = function(){ alert('";
//script += message;
//script += "')};";
//ClientScript.RegisterStartupScript(this.GetType(), "SuccessMessage", script, true);
}
}
Note:
It doesn't show any error message and it is not reloading the page as well. It was weird.
I call jquery functions, after it execute also it never call the server code. For testing purpose, I removed the entire jquery code for this button. So no Jquery function for this button now. But still I couldn't call the server side code why???
UPDATED
I found something, I have one button on the form called btnSave, once user click it will call
$('#btnSave').click(function () {
$('#saveDialog').dialog();
});
IMPORTANT NOTE: Then Dialog box will appear. In that dialog box I have added that button btnSaveFile. But When I add this button outside the dialog, it's calling the server side code.
Hey friend protected void btnSaveFile_Click(object sender, EventArgs e) copied this method from other page or application then it will not work, So delete the event and event name assigned to the button. Go to design and go to button even properties go to OnClick event double click it, It will generate event and automatically assigns event name to the button. It will work.
Or
Give the new Onclick function name in the code
<asp:Button ID="btnSaveFile" runat="server" Text="Save" OnClick="btnSaveFile_Click"/>
Use full Links:
asp.net Button OnClick event not firing
ASP.NET button not firing on click event
OnClick events not working in ASP.NET page
https://www.codeproject.com/Questions/681648/button-click-event-not-firing-asp-net
You may use this code in Jquery:
$(document).on('click', '#btnSave', function() {
{
$('#saveDialog').dialog();
});

Add/Remove Class Using Jquery (In View Or Code Behind)

I have an asp.net webfore application which on the page i have an accordion and in that it has some fields. On the first asp:textbox it has an onclick as it checks my db to see if the user exists or not. If they do an asp:Label is then displayed.
The issue i have is that when ever i click outside or tab out this field my accordion closes and i need it to stay open. I was think though is is possible to do this via JQuery even though my field has the onclick or do i need to add it to my code behind?
In my view i tried
$("#MainContent_txtRemoveUser").on("blur", function ()
{
if ($('#MainContent_txtRemoveUser').val() != '')
{
$('panel-collapse collapse').removeClass('collapse');
$(this).addClass('in');
}
});
but it doesn't work
In my code behind i tried
#region Checks if user exists in 'Users' db when field clicked out of
protected void txtRemoveUser_TextChanged(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(txtRemoveUser.Text))
{
string connection = ConfigurationManager.ConnectionStrings["PaydayLunchConnectionString1"].ConnectionString;
SqlConnection conn = new SqlConnection(connection);
conn.Open();
SqlCommand cmd = new SqlCommand("SELECT 1 FROM Users WHERE Name = #Name", conn);
cmd.Parameters.AddWithValue("#Name", txtRemoveUser.Text);
SqlDataReader rd = cmd.ExecuteReader();
if (rd.HasRows)
{
removeUserNotExist.Visible = false;
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "tmp", "<script type='text/javascript'>function endRequestHandler(sender, args){$('#collapseOne').collapse.in()};</script>", false);
}
else
{
removeUserNotExist.Visible = true;
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "tmp", "<script type='text/javascript'>function endRequestHandler(sender, args){$('#collapseOne').collapse.in()};</script>", false);
}
}
}
#endregion
but this too doesn't work
The HTML of my accordion is
<div id="RemoveUser" class="panel-group">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne" class="accordion-toggle collapsed">Remove Users From The List</a>
</h3>
</div>
<div id="collapseOne" class="panel-collapse collapse">
<div class="panel-body">
<p>If you would like to remove yourself or someone else from the list, please populate all the fields below ensuring to enter the <b>FULL</b> name of the user (whether its you or another user) and then click the 'Remove From List' button.</p>
<asp:Label ID="removeUserNotExist" runat="server" Text="The user entered does not exist. Please try again." Visible="false" style="color: red"></asp:Label>
<div class="form-group">
<asp:Label runat="server" AssociatedControlID="txtRemoveUser" CssClass="col-sm-offset-2 col-sm-3 control-label">Enter Name To Be Removed</asp:Label>
<div class="col-sm-3">
<asp:TextBox runat="server" ID="txtRemoveUser" CssClass="form-control" AutoPostBack="true" OnTextChanged="txtRemoveUser_TextChanged" />
</div>
</div>
<div class="row">
<div class="col-sm-offset-8 col-sm-3" style="padding-left: 0px">
<asp:Button runat="server" ID="btnRemoveUser" Text="Remove From List" CssClass="btn btn-danger" data-toggle="modal" data-target="#removeUserModal" data-backdrop="static" data-keyboard="false" ToolTip="Click to remove the specified user from the payday lunch list." />
</div>
</div>
</div>
</div>
</div>
</div>
None of these appear to work. I may be completly wrong in what i have done though.
The state of the accordion is getting lost on postback (which gets triggered on the textbox's text change event). One way to handle this is to maintain the value in a hidden field and then use this value to reset the accordion.
In .aspx add
<asp:HiddenField runat="server" ID="SetAccVisible" />
Then the corresponding javascript changes to:
$('document').ready(function () {
var hdnFldId = '<%= SetAccVisible.ClientID %>';
$("#txtRemoveUser").on("blur", function () {
//Set value of hidden field to show panel after postback
$('#' + hdnFldId).val(true);
});
if ($('#' + hdnFldId).val() == 'true') {
showPanel();
//lets reset the value
$('#' + hdnFldId).val(false);
}
function showPanel() {
if ($('#MainContent_txtRemoveUser').val() != '') {
$('.panel-collapse').removeClass('collapse').addClass('in');
}
}
});
You are missing class selector to target element. It should be:
$('.panel-collapse.collapse').removeClass('collapse');
In your Jquery, you have a little problem with your selector :
$("#MainContent_txtRemoveUser").on("blur", function ()
{
if ($('#MainContent_txtRemoveUser').val() != '')
{
$('.panel-collapse .collapse').removeClass('collapse');
$(this).addClass('in');
}
});
You forget the point before the class selector ;)
You can read more about JQuery selector here =>
https://api.jquery.com/class-selector/
Also, you can optimize your Jquery code :
$("#MainContent_txtRemoveUser").on("blur", function ()
{
if ($(this).val()) // == if $(#MainContent_txtRemoveUser).val() != ""
{
$('.panel-collapse .collapse').removeClass('collapse');
$(this).addClass('in');
}
});
You check the value of the selector's function (#MainContent_txtRemoveUser")
You can use the '$(this)' selector for call it again, in the function. ^^
And, don't forgot you can use a breakpoint in your browser for check your javascript!
Hope I help you :p

Send info to code behind without postback

First, I'm a student, though this is not for school. I'm trying to create a contact us page for my church's website (http://fpcoakwood.azurewebsites.net). I haven't published the contact page yet, as I'm trying to build it. I'm using Bootstrap/jQuery/ASP.NET to build the site. There is a videos page that uses ASP to get the list of videos from YouTube for our channel, and then populates the select html element from that, and I have it working so that selecting a different video loads that video into the player without a postback (though I do wish I could make the back button take me back to the prior page, rather than cycling through prior videos first).
On this page, my challenge is that I'm trying to send an email. I have the code behind working so that I can send the email, but I'm also trying to disable the send button and fadeIn a result div, which would show either success or failure to send the email. The problem is that because the postback occurs, the page reloads, and I lose the disabling of the button and the showing of the status.
Here's some of the code I have so far:
HTML:
<div class="form-group">
<asp:Button class="btn btn-success" ID="sendMail" OnClick="sendMail_Click" OnClientClick="sendMail(); return false;" runat="server" UseSubmitBehavior="false" Text="Send Message" />
</div>
<div id="sendSuccess" runat="server">Success!</div>
<div id="sendFailed" runat="server">Unable to send message. Please try again later.</div>
JS:
$("#sendMail").click(function (event) {
event.preventDefault();
$("#sendSuccess").fadeOut();
$("#sendFailed").fadeOut();
$("#sendMail").attr("disabled", true);
$("#sendMail").attr("text", "Sending...");
return true;
});
C#:
protected void sendMail_Click(object sender, EventArgs e)
{
//sendMail.Enabled = false;
//sendMail.Text = "Sending...";
SendMessage();
}
If I get rid of the javascript function, I can send the email. It goes through no problems. But with the javascript function, the breakpoint in the C# function is never hit, so it's not hitting the server. What I want is to be able to validate in js before sending to the server, then send to the server without a postback, and have the server send a message to the js allowing either the fail or the success message div to fadeIn().
Any help will be VERY much appreciated. Thanks in advance!
The jquery function runs before the C# code behind and interfere with it's result.
To do what you want you could do all the work on the server-side.
You can use ajax to do that.
Use an updatepanel around the controls and an updateprogress with the "sending..." message. Capture the sendmessage() result and then show the #sendsuccess or #sendFailed according to it.
I ended up using the answer in this post (How to call code behind method from a javascript function?) to do what I wanted to do. Surely it could have been done with Filipe's answer, but at this point, I'm already drinking from a fire hose trying to learn what I can learn, so this was easier for me, since I already have a fair understanding of all of the pieces involved.
Here's my HTML:
<form runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true"></asp:ScriptManager>
<div class="col-md-8 col-md-offset-2" runat="server">
<div class="form-group">
<label for="userName">Your name (requrired):</label>
<input type="text" class="form-control" id="userName" runat="server" />
</div>
<div class="form-group">
<label for="email">Email address (required):</label>
<input type="email" class="form-control" id="email" runat="server" />
</div>
<div class="form-group">
<label for="message">Message:</label>
<textarea class="form-control" id="message" rows="5" runat="server"></textarea>
</div>
<div class="form-group">
<asp:Button class="btn btn-success" ID="sendMail" runat="server" OnClientClick="sendMail(); return false;" UseSubmitBehavior="false" Text="Send Message" />
</div>
<div id="sendSuccess" runat="server">Your message has been sent. Thank you for contacting First Pentecostal Church of Oakwood. You are important to us!</div>
<div id="sendFailed" runat="server">Unable to send message. Please try again later. You are important to us!</div>
</div>
</form>
There is an error in the HTML, as the OnClientClick doesn't find the function, but without it and the return false, the page does a postback. I'm not sure how to fix it, as the preventDefault() in the JS doesn't solve it, and using the UseSubmitBehavior by itself doesn't do it, either. But this works, though it shows as an error in the developer tools in the browser.
Here's the CSS:
#sendSuccess,
#sendFailed {
display:none;
border: 1px solid black;
border-radius: 5px;
padding: 5px;
}
#sendSuccess {
background-color: rgba(147, 197, 75, .7);
}
#sendFailed {
background-color: rgba(201, 48, 44, .7);
}
Here's the JavaScript:
//Set up event handler for send message contact page button
$("#sendMail").click(function (event) {
event.preventDefault();
sendMail();
});
//above is in the $(document).ready function
function sendMail() {
$("#sendSuccess").fadeOut();
$("#sendFailed").fadeOut();
$("#sendMail").prop("value", "Sending...");
$("#sendMail").attr("disabled", true);
var name = $("#userName").val();
var email = $("#email").val();
var msg = $("#message").val();
PageMethods.SendMessage(name, email, msg, onSuccess, onError);
}
function onSuccess(result) {
if (result) {
$("#sendSuccess").fadeIn();
$("#userName").prop("value", "");
$("#email").prop("value", "");
$("#message").prop("value", "");
$("#sendMail").prop("value", "Send Message");
$("#sendMail").attr("disabled", false);
}
else { onError(result); }
}
function onError(result) {
$("#sendFailed").fadeIn();
$("#sendMail").prop("value", "Try Again");
$("#sendMail").attr("disabled", false);
}
And here's the C#:
[System.Web.Services.WebMethod()]
public static bool SendMessage(string user, string email, string msg)
{
string to = "xxxxxxxxx#outlook.com";
string from = "xxxxxxxxxx#outlook.com";
string subject = "Message from OakwoodFPC.org Contact Page";
string body = "From: " + user + "\n";
body += "Email: " + email + "\n";
body += msg;
MailMessage o = new MailMessage(from, to, subject, body);
NetworkCredential cred = new NetworkCredential("xxxxxxxxxx#outlook.com", "password");
SmtpClient smtp = new SmtpClient("smtp.live.com", 587);
smtp.EnableSsl = true;
smtp.Credentials = cred;
try
{
smtp.Send(o);
return true;
}
catch (Exception)
{
return false;
}
}

Webmail confirmation without new page

I have used this method: http://www.asp.net/web-pages/overview/getting-started/11-adding-email-to-your-web-site
to allow website users to submit Name and Email.
Using this method I have a simple form on one page, which then opens a new page to process the form, sends the email and returns a success message. This works fine in itself, but I would prefer to avoid opening the new page for processing.
(I tried putting all the code on the start page, but then it sends a mail whenever the page loads)
I would much prefer to either replace the form's div with the success message, or pop up a modal with the success message, but I'm not sure how to go about doing this.
I tried putting the processing code in a modal (bootstrap 3), but I don't know how to pass the variables (user input) to the modal (modal being in a separate file to avoid the aforementioned sending on page load behavior)
The processing page (ProcessRequest.cshtml) is as follows:
#{
var customerName = Request["customerName"];
var customerEmail = Request["customerEmail"];
var sub = Request["sub"];
var errorMessage = "";
var debuggingFlag = false;
try
{
// Send email
WebMail.Send(to: "email#hotmail.com",
subject: "Form submitted on HMD. Name: " + customerName + " Email: " + customerEmail,
body: "Submitted details: " + Environment.NewLine + "Name: " + customerName + Environment.NewLine + "Email: " + customerEmail + Environment.NewLine + "Subscribe: " + sub, isBodyHtml: false
);
}
catch (Exception ex)
{
errorMessage = ex.Message;
}
}
<p>Thankyou for submitting your email, <b>#customerName</b>.
Back
And the form itself is as follows:
<form class="form-inline" method="post" action="~/ProcessRequest.cshtml">
<div class="form-group col-xs-9">
<input type="text" placeholder="Name" name="customerName" class="form-control txt-primary clearable" />
</div>
<div class="form-group col-xs-9">
<input type="email" placeholder="e-mail" id="customerEmail" name="customerEmail" class="form-control txt-primary clearable" />
</div>
<button type="submit" value="submit" data-target="#modal" class="test input-append btn btn-primary col-xs-2"><span class="glyphicon glyphicon-ok"></span></button>
<div class="form-group col-xs-12">
<input id="checkbox" type="checkbox" name="sub" value="Yes" checked/> Subscribe to newsletter
</div>
</form>
I would greatly appreciate any advice on how to achieve this!
I'm not sure whether I should be trying to use AJAX or some other method, I've yet to learn how to use AJAX so if this would be my best option, a pointer to a decent (preferably comprehensible for beginners) tutorial would be nice :)
UPDATE
Ok, So I am attempting to use an iframe as suggested... But so far have not been able to get the data to submit.
I've not used iframe before, so I'm not sure what I'm doing!
I have added a hidden iframe like so:
<iframe class="hidden" name="iframe_submit"></iframe>
I'm not sure where I should be pointing the form at the iframe.
Previously I had the action of the form pointing at ProcessRequest.cshtml.
I have changed this to formtarget="iframe_submit" is this correct?
I changed the submit button to use a href="~/ProcessRequest....
Now the email is being sent, so the iframe must be loading the ProcessRequest page, however the information from the form is not inserted in the email.
Thanks #mplungjan this worked nicely..
Solution: Hidden iframe
<iframe class="hidden" name="iframe_submit"></iframe>
with
<form class="form-inline" method="post" target="iframe_submit" action="~/ProcessRequest.cshtml">...</form>
and added to the ProcessRequest file:
<script>alert("Thankyou for submitting your email, #customerName.")</script>
Your assistance is very much appreciated, especially since I learnt a new trick!

ASP.NET Contact form issues

I'm setting this form up for a small business, so all the email gets sent directly to their mail server. I input the correct information and the mail successfully sends from the website, but it will never reach their mail server. Their mail server does give errors on the contact form saying 5.7.1 Message rejected as spam by Content Filtering. If it doesn't detect spam it will send, but still the server wont receive it.
Am I doing something wrong with the code or is the mail server rejecting it?
c#
using System;
using System.Net.Mail;
public partial class _Emailer : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
try
{
string output = "";
MailMessage mail = new MailMessage();
// Replace with your own host address
string hostAddress = "xxx.xxx.xxx.xxx";
// Replaces newlines with br
string message = Request.Form["c_Message"].ToString();
message = message.Replace(Environment.NewLine, "<br />");
output = "<p>Name: " + Request.Form["c_Name"].ToString() + ".</p>";
output += "<p>E-mail: " + Request.Form["c_Email"].ToString() + ".</p>";
output += "<p>Phone: " + Request.Form["c_Phone"].ToString() + ".</p>";
output += "<p>Message: " + message + ".</p>";
mail.From = new MailAddress("xxxxxxx#xxxxxx.org");
mail.To.Add("xxxxxxx#xxxxxxx.org");
mail.Subject = "New e-mail.";
mail.Body = output;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient(hostAddress);
smtp.EnableSsl = false;
smtp.Send(mail);
lblOutcome.Text = "E-mail sent successfully.";
}
catch (Exception err)
{
lblOutcome.Text = "There was an exception whilst sending the e-mail: " + err.ToString() + ".";
}
}
}
}
HTML
<asp:label id="lblOutcome" runat="server" />
<form name="contact" method="post" id="cf">
<div id="contactform">
<p><img src="images/required_star.png" alt="Star" /> Required fields for contact form completion</p>
<ol>
<li>
<label for="c_Name" class="required-star">Name:</label>
<input type="text" id="Text1" name="c_Name" placeholder="John Doe" class="required text" minlength="2" value="<% Response.Write(Request.Form["c_Name"]); %>" />
</li>
<li>
<label for="c_Email" class="required-star">Email:</label>
<input type="text" id="Text2" name="c_Email" class="required email text" placeholder="example#domain.com" value="<% Response.Write(Request.Form["c_Email"]); %>" />
</li>
<li>
<label for="c_Phone">Phone:</label>
<input type="text" id="Text3" name="c_Phone" class="phoneUS text" placeholder="ex. (555) 555-5555" value="<% Response.Write(Request.Form["c_Company"]); %>" />
</li>
<li>
<label for="c_Message" class="required-star">Message:</label>
<textarea id="Textarea1" name="c_Message" rows="6" cols="50" class="required" placeholder="..." minlength="2"><% Response.Write(Request.Form["c_Message"]); %></textarea>
</li>
<li class="buttons">
<input title="Submit" class="buttonBlue" value="Submit" type="submit" />
<input title="Clear the form" class="buttonBlue" value="Clear" type="reset" />
</li>
</ol>
</div>
</form>
It looks like this is all down to the mail server filtering the emails. Perhaps contact the email host and explain your problem.
It may be treated as spam because of a lot of reasons. One of them is that from address does not match the host email was sent from. E.g. you are sending email from pop3.yourhost.com and from field is my#name.com
Anyway it seems to have nothing to do with ASP.NET

Categories

Resources