Add function to a Button event in  --  Environment is Visual Studio 2012 Basic

jampost used Ask the Experts™
I need a button called email to take the user to their email program and fill in my email address and subject=Question/Comment. This currently works on my website, but I am changing some things such as putting buttons where there is just text links. Other buttons will just move the user to different pages. I am not sure how to combine the button code with the Mailto or the simple link code. I need to know the syntax of adding function to button code. See below samples.    

<input id="Button1" type="button" value="email"/>
<a href=""title=""><b>email</b></a>
<a href="Equipment.aspx"><b>Equipment</b></a>

Thank you for any help.  --  Joe
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
You could either use javascript or server side code to accomplish this -

In Javascript -

<input id="Button1" type="button" value="email" onclick="email();return false;"/>
    function email() {
        document.location.href = ""title=";

Open in new window

Or you could use server side code -

<asp:Button ID="btnEmail" Text=" Email" runat="server"  OnClick="btnEmail_Click" /> 

using System.Diagnostics;
 protected void btnEmail_Click(object sender, EventArgs e)

            var myUrl = ""title="";


Open in new window

jampostGeneral Maanager


Thank you for your help.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial