473,408 Members | 1,951 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

No button click event

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.CreateNewCate gory"%>
<%@ 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>
Nov 18 '05 #1
2 1325
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.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Lloyd Sheen" <sq*******************@tostopspamhotmail.com> wrote in message
news:5_******************@news04.bloor.is.net.cabl e.rogers.com...
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.CreateNewCate gory"%>
<%@ 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>

Nov 18 '05 #2
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.

--
Matt Berther
http://www.mattberther.com
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.CreateNewCate gory"%>
<%@ 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>


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: yfng | last post by:
In a web form, I want the user clicks on one button and this button will trigger another button/link which will open a new browser window? How to do that? Is there any method like...
2
by: Liqun Xu | last post by:
Hallo NG, I created a Button with Click-Event dynamically: System.Web.UI.WebControls.Button bt_1 = new Button(); bt_1.Click += new EventHandler(bt_1_click); and I implemented the Funktion...
6
by: Michael Johnson Jr. | last post by:
I am trying to handle a button click event, which updates a web control table with data. The button is dynamically created in the table itself. When I call updateTable() in the Page_Load the new...
4
by: Mark Lingen | last post by:
I've found a problem with postback event handling and webcontrol buttons. Try out the following code in an ASP.Net project and you will see. Create a web project in VB.Net and drop this code...
11
by: CW | last post by:
I have message entry screen that's causing me a bit of an issue. At the moment, there are 2 buttons, one is used to send message to another user (btnSend) and another is used to send messages to...
3
by: Imran Aziz | last post by:
Hello All, I have a search text and button that post data and my button handler filters the repeater control. However when the button is clicked the first time. The page_load event is being called...
7
by: MgGuigg | last post by:
Hello all, This is my first time posting a question to this forum, so here is hoping I am following protocol. I am scraping the rust off my old Basic programming skills, and have just recently...
15
by: Oleg Subachev | last post by:
I need to programmatically invoke from other class Click event of the Button on my Form. Button.OnClick method is protected, not public. How to perform this ? Oleg Subachev
7
by: =?Utf-8?B?bWFydGluMQ==?= | last post by:
Hi, All, I create button in the code ( Dim Button as new Button), not using button web component (means not drap button and drop it ont he webform), after that I try to use button_click event,...
3
by: GauravGupta | last post by:
i want to know that is it posible to call button click event before page load event on post back.... please help me....
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.