使用ASP.NET提交HTML表单。 [英] Using ASP.NET to submit an HTML form.

查看:73
本文介绍了使用ASP.NET提交HTML表单。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

请帮助我,我没有在asp.net发送电子邮件。我的服务提供商不允许使用smtp,所以我必须将我的表单发布到他们给我的页面,以便他们可以将其转发到我的电子邮件。

i有这样的内容:



Hi guys
please help me I am failing to send an email in asp.net. my service provider does not allow the use of smtp, so i have to post my form to a page they gave me so that they can forward it to my email.
i have something like this:

<form method="post" action="http://their_page.com/mailto/mailto.pl">
<input type="hidden" name="followup-page" value="http://my_follo_page.com/mailto/confirm.html">
<input type="hidden" name="recip" value="email@domain.co.za">
<input type="hidden" name="subj" value="Feedback Form"> 
<input type="hidden" name="from" value="email@domain.co.za"> 
<input type="hidden" name="body"





如何在ASP.net中执行此操作,我需要这个,因为我的网站是在ASP中开发的?

当我这样做html,它工作正常,但不能使用ASP.NET页面(当我点击提交没有任何反应)我不能使用HTML因为看起来,我不能使用ASP带有html页面的.NET母版页。





另外,我如何修改register.asp页面发送确认电子邮件谁有人注册?我只知道如何使用smtp发送电子邮件,如何将用户名和电子邮件发布到该服务器页面?这是我的register.aspx.cs:



How can i do this in ASP.net, i need this because my website is developed in ASP?
when i do it html, it works fine but doesnt work with an ASP.NET page (nothing happens when i click submit ) and i cannot use HTML because of the look, i cant use the ASP.NET master page with html page.


The other thing, how can i modify my register.asp page to send an confirmation email when somebody register? i only know how to send email with smtp, how can i post the username and email to that server page? this is my register.aspx.cs:

namespace WebApplication1.Account
{
    public partial class Register : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            RegisterUser.ContinueDestinationPageUrl = Request.QueryString["ReturnUrl"];
        }
        protected void RegisterUser_CreatedUser(object sender, EventArgs e)
        {
           MembershipUser newUser = Membership.GetUser(RegisterUser.UserName);
            Guid newUserID = (Guid)newUser.ProviderUserKey;
            string urlBase = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath;
            string verifyUrl = "VerifyNewUser.aspx?ID=" + newUserID.ToString();
            string fullPath = urlBase + verifyUrl;
            string appPath= Request.PhysicalApplicationPath;
           StreamReader sr = new StreamReader(appPath + "EmailTemplates/VerifyNewUser.txt");
           MailMessage message = new MailMessage();
            message.IsBodyHtml = true;
           message.From = new MailAddress("studentcompanionsa@gmail.com","Student Companion");
            message.To.Add( new MailAddress(RegisterUser.Email));
           message.CC.Add(new MailAddress("membership@studentcompanion.co.za"));
            message.Subject = "New User Registration";
            message.Body = sr.ReadToEnd();
            sr.Close();
            message.Body = message.Body.Replace("<%UserName%>", RegisterUser.UserName);
            message.Body = message.Body.Replace("<%VerificationUrl%>", fullPath);
            SmtpClient client = new SmtpClient();
           client.EnableSsl = true;
           client.Send(message);
            //FormsAuthentication.SetAuthCookie(RegisterUser.UserName, false /* createPersistentCookie */);
            string continueUrl = RegisterUser.ContinueDestinationPageUrl;
            if (String.IsNullOrEmpty(continueUrl))
            {
                //continueUrl = "~/";
                continueUrl = "~/RegisterEmailNotification.aspx";
            }
            Response.Redirect(continueUrl);
            
        }
    }
}









非常感谢。





THANK YOU VERY MUCH.

推荐答案

为了解决第一个问题,我想它会是这样的。



自从我写了一个表单提交给另一个表单已经有很长一段时间了,它是用PHP编写的,但这是我的版本如何在asp.net中执行此操作,并保留输入密钥提交。



您可能必须重命名文本框的ID并取出前缀txt_ ,我忘记了name属性的用途。



我利用4.0 clientIDMode将控件设置为静态,以保持正确的名称和id值。



To help on the first question, I think it would go something like this.

It''s been a long time since I''ve written a form to submit to another form, it was in PHP, but this is my version of how to do it in asp.net, and retain the enter key submission.

You may have to rename the ID''s of the textbox and take out the prefix txt_, I forget what the name attribute is for.

I took advantage of 4.0 clientIDMode as set the controls as static to maintain the proper name and id values.

<![CDATA[<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>]]>


为了解决第一个问题,我认为它会是这样的。



自从我写了一个表单提交给另一个表单已经有很长一段时间了,它是用PHP编写的,但这是我的版本如何在asp.net中执行此操作,并保留输入密钥提交。



您可能必须重命名文本框的ID并取出前缀txt_ ,我忘记了name属性的用途。



我利用4.0 clientIDMode将控件设置为静态,以保持正确的名称和id值。



To help on the first question, I think it would go something like this.

It''s been a long time since I''ve written a form to submit to another form, it was in PHP, but this is my version of how to do it in asp.net, and retain the enter key submission.

You may have to rename the ID''s of the textbox and take out the prefix txt_, I forget what the name attribute is for.

I took advantage of 4.0 clientIDMode as set the controls as static to maintain the proper name and id values.

<form id="form1" runat="server">
<div>
    <asp:panel id="panel_emailSubmit" runat="server" style="width: 350px; text-align: left;" defaultbutton="bt_Submit" clientidmode="Static" xmlns:asp="#unknown">
        <table cellpadding="0" cellspacing="0" border="0" style="width: 350px;">
            <tr>
                <td style="width: 350px; height: 96px; text-align: left;">
                    <asp:textbox runat="server" id="txt_recip" clientidmode="Static">email@domain.co.za</asp:textbox><br />
                    <asp:textbox runat="server" id="txt_subj" clientidmode="Static">Feedback Form</asp:textbox><br />
                    <asp:textbox runat="server" id="txt_from" clientidmode="Static">email@domain.co.za</asp:textbox><br />
                    <asp:textbox runat="server" id="txt_body" clientidmode="Static"></asp:textbox><br />
                </td>
            </tr>
            <tr>
                <td style="width: 350px; height: 46px; text-align: left;">
                    <asp:button runat="server" text="Button" id="bt_Submit" postbackurl="http://their_page.com/mailto/mailto.pl" clientidmode="Static" />
                </td>
            </tr>
            <tr>
                <td style="width: 350px; height: 0px; text-align: left;">
                    <input type="hidden" name="followup-page" value="http://my_follo_page.com/mailto/confirm.html" />
                </td>
            </tr>
        </table>
    </asp:panel>
</div>
</form>


这篇关于使用ASP.NET提交HTML表单。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆