c#中提交按钮的代码 [英] code for submit button in c#

查看:106
本文介绍了c#中提交按钮的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,有人可以帮助我,我想知道c#中提交按钮的代码,所以当有人按下按钮时,它会向我的电子邮件地址发送一封电子邮件

解决方案

按钮代码?我不认为你需要这个,但是人们应该得到他们应得的答案。

 <  表格    ...  >  
< 输入 < span class =code-attribute> type = submit value = 提交 >
< / form >



请参阅: http://www.w3schools.com /Tags/att_input_type.asp [ ^ ] 。



如果你这样做,表格中的所有数据(每个属性 name 及其值)将自动放入单个HTTP请求并发送到服务器端。这就是Web表单的工作方式。您有责任在服务器端处理表单数据。



至于电子邮件,请格外小心。这是一个非常脆弱的问题。一个错误的举动,你的服务器主机将变成一个僵尸发送垃圾邮件,或类似的东西,在任何时候。在表单数据中注入恶意代码只是孩子的游戏。甚至不想按原样发送任何数据。为避免漏洞利用,请参阅我之前的回答:

无法发送邮件,它显示以下代码中的错误。 [ ^ ]。



-SA


如果有asp按钮,为什么需要使用提交按钮?

试试这个



< asp:button id =  按钮 runat =   server onclick =  单击 cssclass =  联系人 xmlns:asp =  #unknown >  
// 如果你不想使用asp:按钮

< button id = 按钮 runat = server OnServerClick = 点击 >
< / asp:按钮 >





代码背后



  protected   void 点击(对象发​​件人,EventArgs e)
{
// 发送电子邮件
}


使用ASP.NET和C#发送邮件/联系表单 [ ^ ]

Hello, could someone please help me, I would like to know the code for the submit button in c# so when someone presses the button it sends a email to my email address

解决方案

"Code for button"? I don't think you need exactly, this, but people should get answers their questions deserve.

<form ...>
    <input type="submit" value="Submit">
</form>


Please see: http://www.w3schools.com/Tags/att_input_type.asp[^].

If you do it this way, all data in the form (per attributes name and their values) will be automatically put to a single HTTP request and sent to the server side. This is how the Web form work. This is your responsibility to process form data on the server side.

As to e-mails, be extra careful. This is a very vulnerable points. One wrong move, and your server host will be turned into a zombie sending spam, or something like that, in no time. Injection of malicious code in form data is just a kid's play. Don't even play with the idea of sending any data as is. To avoid the exploit, please see my past answer:
unable to send mail , it showing the error in below code .[^].

—SA


why do you need to use submit button if there is an asp button?
try this

<asp:button id="button" runat="server" onclick="click" cssclass="contact" xmlns:asp="#unknown">
//If you don't want to use the asp:button

<button id="button" runat="server" OnServerClick="click" >
</asp:button>



in code behind

protected void click(object sender, EventArgs e)
{
    //do send email
}


Send Mail / Contact Form using ASP.NET and C#[^]


这篇关于c#中提交按钮的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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