Click here to Skip to main content
11,578,954 members (65,528 online)
Rate this: bad
good
Please Sign up or sign in to vote.
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">
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 8-Jan-13 18:44pm
Edited 8-Jan-13 19:24pm
v3

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
Zafar Sultan at 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
0 Peter Leow 115
1 Frankie-C 115
2 OriginalGriff 113
3 Afzaal Ahmad Zeeshan 85
4 Richard MacCutchan 85
0 OriginalGriff 933
1 Sergey Alexandrovich Kryukov 740
2 Abhinav S 573
3 F-ES Sitecore 420
4 Dave Kreskowiak 419


Advertise | Privacy | Mobile
Web04 | 2.8.150603.1 | Last Updated 9 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100