Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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">

C#
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?
Posted
Updated 8-Jan-13 19:24pm
v3

1 solution

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.
 
Share this answer
 
Comments
Zafar Sultan 9-Jan-13 3:39am    
*****

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900