No button click event

L

Lloyd Sheen

I have a simple page with a text box and a button. The code for the button
will insert the text into SQL Server. When I click the button no code gets
invoked (not even a page load). Other pages work just fine, I have deleted
the button several times and reinserted it with no luck.

VS2003/XP Pro/

VB Code (Codebehind):

Private Sub btnAddNewCategory_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnAddNewCategory.Click
Dim products As ASPNET.StarterKit.Commerce.ProductsDB = New
ASPNET.StarterKit.Commerce.ProductsDB
Dim psCategoryId As String
psCategoryId = products.AddNewCategory(Me.txtCategoryName.Text)
Me.lblStatus.Text = "Added new Category - " + Me.txtCategoryName.Text + "
Category ID = " + psCategoryId
BindCategories()
End Sub

Page Code :

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="CreateNewCategory.aspx.vb"
Inherits="ASPNET.StarterKit.Commerce.CreateNewCategory"%>
<%@ Register TagPrefix="uc1" TagName="_Menu" Src="_Menu.ascx" %>
<%@ Register TagPrefix="uc1" TagName="_Header" Src="_Header.ascx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>CreateNewCategory</title>
<LINK href="ASPNETCommerce.css" type=text/css rel=stylesheet >
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name=vs_defaultClientScript content="JavaScript">
<meta name=vs_targetSchema
content="http://schemas.microsoft.com/intellisense/ie3-2nav3-0">
</HEAD>
<body MS_POSITIONING="FlowLayout">

<form id="Form1" method="post" runat="server">
<P><uc1:_Header id=_Header1 runat="server"></uc1:_Header></P>
<P>
<TABLE id=Table3 cellSpacing=1 cellPadding=1 width="100%" border=1>
<TR>
<TD>
<P><uc1:_Menu id=_Menu1 runat="server"></uc1:_Menu></P></TD>
<TD>
<TABLE id=Table1 cellSpacing=1 cellPadding=1 width="100%" border=1>
<TR>
<TD>
<P align=right>Current Categories : </P></TD>
<TD><asp:DropDownList id=ddCategoryList runat="server"
Width="214px"></asp:DropDownList></TD></TR>
<TR>
<TD></TD>
<TD></TD></TR>
<TR>
<TD>
<P align=right>New Category Name : </P></TD>
<TD><asp:TextBox id=txtCategoryName
runat="server"></asp:TextBox></TD></TR>
<TR>
<TD>
<P align=right>&nbsp;</P></TD>
<TD><asp:Button id=btnAddNewCategory runat="server" Text="Add
Category"></asp:Button></TD></TR></TABLE></TD></TR></TABLE></P>
<P>&nbsp;</P>
<TABLE id=Table2 cellSpacing=1 cellPadding=1 width="100%" border=0>
<TR>
<TD>
<P
align=center><asp:Label id=lblStatus
runat="server">...</asp:Label></P></TD></TR></TABLE>

</form>

</body>
</HTML>
 
S

Steve C. Orr [MVP, MCSD]

Sounds like your page is corrupted in some way.
Perhaps you should start again with a new page.
The only other thing I can think of is that the page might be being cached
somewhere.

You can put this code in any pages that you don't want to get cached:
Response.Expires = 0
Response.Cache.SetNoStore()
Response.AppendHeader("Pragma", "no-cache")

But if the code behind for your page is never being exectuted then neither
will this code! Obviously this code needs to be executed before it can take
effect.
 
M

Matt Berther

Hello Lloyd,

Make sure that the btnAddNewCategory_Click event is actually hooked up.

In C#, you'd look in the OnInit() method. I'm sure VB.NET is the same.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top