1

I'm pretty new to asp.net and for the life of me i cant seem to get the submit button to call the relevent vb code. Can anyone point me in the right direction? I've stripped almost everything out and left it to just show a message box but nothing, no errors, no warnings. Would seriously appreciate any help here.

Register.aspx

<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/anonymous/anonymous.Master" CodeBehind="register.aspx.vb" Inherits="mynamespace.register" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <form id="register" method="post">
    <asp:Label ID="EmailLabel" runat="server" AssociatedControlID="Email">E-mail:</asp:Label>
    <asp:TextBox ID="email" runat="server" CssClass="textEntry"></asp:TextBox><br />

    <asp:Button ID="submit" runat="server" Text="Create Account"/>
    </form>         
</asp:Content>

register.aspx.vb

Imports System.Web.Configuration
Imports System.Data.SqlClient

Public Class register
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Private Sub submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles submit.Click
        MsgBox("submit clicked!!", 65600, "New Message")
    End Sub

End Class
1
  • 3
    Set a breakpoint at the line with the MsgBox and you'll see that it gets hit. You cannot show a message box in ASP.NET since it would be shown at the server and not at the client. Commented Nov 26, 2012 at 21:56

2 Answers 2

2

Set a breakpoint at the line with the MsgBox and you'll see that it gets hit. You cannot use a message-box in ASP.NET since it would be shown at the server and not at the client.

for demonstration purposes you could register a clientside alert:

Private Sub submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles submit.Click
    ClientScript.RegisterStartupScript(this.GetType(), "msgBox", "alert('submit clicked! Now at the client again');", true);
End Sub
Sign up to request clarification or add additional context in comments.

Comments

1

I see two issues here.

The first is that you should not be using a form tag inside your content. There is already a form on your page for this as part of your master page, and using a separate form here means you are not creating a proper postback... things like viewstate are not submitted correctly and thus the asp.net runtime doesn't know to fire the click event handler.

The second is that the MsgBox() function will not work as you expect (really: will not work at all) in webforms. You need to do something different for this kind of debugging in asp.net, such as log to a file or set a break point.

1 Comment

thats just there from me trying it with and without a form tag. made no difference either way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.