Click Events for Image Button

Discussion in 'ASP.NET / ASP.NET Core' started by Karen, Mar 19, 2005.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Help! I am relatively new to ASP.NET programming, specifically to using Visual Studio .NET. I am attempting to have the click event of an ImageButton do two things... Firstly, I want an email sent using the contents of textboxes on the page. Secondly, I want the user to be directed to a new web page. I have done this successfully before, however I was building the HTML using FrontPage, then opening the file in a text editor and adding the ASP.NET code. Now, I'm using VS .NET and am trying to implement the Codebehind module that opens up when you double-click the ImageButton. The code I am using is:




    Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnSubmit.Click


    If Page.IsValid Then


    Dim mailMessage As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage


    mailMessage.From = "[email protected]"


    mailMessage.To = "[email protected]"


    mailMessage.Subject = "Request"


    mailMessage.BodyFormat = System.Web.Mail.MailFormat.Html


    mailMessage.Body = "text to appear in the body of the email message"


    ' Code for the body has been snipped out for length purposes


    System.Web.Mail.SmtpMail.SmtpServer = "localhost"


    System.Web.Mail.SmtpMail.Send(mailMessage)


    Response.Redirect("ask_expert_response.aspx")


    End If


    End Sub


    When I click the ImageButton, the page just posts back to the server, and neither sends an email, nor redirects to a new page. Can anybody tell me where I might have gone wrong? Is there anything else I need to be doing? Thanks in advance!
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    i would put something in the sub to make sure it is fired.

    put

    response.write ('In btnSubmit_click')

    before

    If Page.IsValid Then

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page