在asp.net中未触发的文本框值 [英] textbox value not fired in asp.net

查看:62
本文介绍了在asp.net中未触发的文本框值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<input type="text" name="contactFormName" id="name"  onfocus="clearInput(this,'focus','Enter your name')"  önblur="clearInput(this,'blur','Enter your name')"  runat="server" />

<input type="text" name="contactFormEmail" id="mail"  onfocus="clearInput(this,'focus','Enter your e-mail')"  önblur="clearInput(this,'blur','Enter your e-mail')"  runat="server" />
												<textarea name="contactFormMessage" id="msg" rows="0" cols="0" onfocus="clearInput(this,'focus','Enter your message')"  runat="server"   önblur="clearInput(this,'blur','Enter your message')"></textarea>

<input id="but"  runat="server" name="contactFormSend" onblur="clearInput(this,'blur','Send')"

               onfocus="clearInput(this,'focus','Send')" type="button" value="Send" style="width: 100px"  önserverclick="but_ServerClick">




protected void but_ServerClick(object sender, EventArgs e)
    {
        try {
            string to = "sample@gmail.com";
            MailMessage email = new MailMessage();
            email.To.Add(to);
            MailAddress maFrom = new MailAddress("sample@gmail.com");
            email.From = maFrom;
            
            email.Subject = "Contact Detail";
            email.IsBodyHtml = true;//this is only if you are sending an html message
            email.Body = "<html><body> <font face="\"Cambria\"" size="\"3\""><center><h3>Registration</h3></center><br />Name :" + name.Value  + "<br /><br /> Email ID :" + mail.Value  + "<br /><br /> Message : " +msg.Value+ "<br /><br /></font></body></html>";
            SmtpClient smtp = new SmtpClient("smtp.gmail.com", 25);
            smtp.EnableSsl = true;
            smtp.Credentials = new System.Net.NetworkCredential("sample@gmail.com", "sample");
            smtp.Send(email);
            
        
        }
        catch (Exception ex)
        {
            Exception E = ex;
        }
    }





这里我的按钮点击未捕获我的输入文本..它发送邮件名称:输入您的姓名。



邮件输入您的邮件



任何人都可以帮助我吗?



Here my button click not captured my input text.. It sends mail as Name: Enter your Name.

Mail as Enter your mail

Can anyone help me?

推荐答案

我的按钮点击未捕获我的输入文字。

怎么回事?您已经编写了正确发生的事情的代码。您已在输入文本框上设置 onblur 事件。那一刻,你按下按钮, onblur 将被调用,一切都将被重置。



看起来像一个onfocus&的复制粘贴没有任何思想理由或需要的onblur事件。首先,删除 onblur 事件,看看情况如何。我建议您删除onfocus的调用,因为在您需要非常具体的内容之前,这一点没有多大意义。
my button click not captured my input text.
How would it? You have written code for exactly what is happening right now. You have set onblur event on the input textboxes. The moment, you press your button, onblur will be called and everything will be reset.

Looks like a copy-paste of onfocus & onblur events without any thought reason or need. To start with, remove the onblur event and see how things go. I would suggest to remove calls of onfocus too that you make on button as that does not make much sense until you need something very specific.


这篇关于在asp.net中未触发的文本框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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