Click here to Skip to main content
13,000,323 members (52,933 online)
Rate this:
Please Sign up or sign in to vote.
See more:
<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 = "";
            MailMessage email = new MailMessage();
            MailAddress maFrom = new MailAddress("");
            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("", 25);
            smtp.EnableSsl = true;
            smtp.Credentials = new System.Net.NetworkCredential("", "sample");
        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
Updated 8-Jan-13 19:24pm

1 solution

Rate this: bad
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.
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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170624.1 | Last Updated 9 Jan 2013
Copyright © CodeProject, 1999-2017
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