Click to See Complete Forum and Search --> : click event does not seem to be working


yardleybates
05-12-2004, 01:29 PM
Trying to avoid the words "Help" and "Newbie" but I am just starting out at trying to convert .asp pages to .NET and .aspx and I am really not doing so well so far.

I have 2 events in my c# code behind on my aspx page.

The Page_Load and the Submit_Click

I have all the data loading in the Page_Load surrounded by
if(!IsPostBack) {}

And yet when I click on the button it seems as though the page just reloads and doesn't actually do any of the things I am asking it to in the Submit_Click. I have tried adding a Response.Write and a Label text set and am getting no visible response.

Response.Write("Give me a break");
Label1.Text="Testing label text set";

Thanks as always for any help. This is the best forum and people always are so helpful (thank goodness):p

CardboardHammer
05-12-2004, 05:09 PM
Do you have the runat attribute of the INPUT control set to "server"? Also, do you have it declared "WithEvents" in the codebehind?

If you hand wrote it, you might have missed one or both of those...

(NOTE: I use VB.NET, not C#, but the general ideas are the same.)

tomhartland
05-13-2004, 05:31 AM
Have you added the event handler delegate for the click event?

Try using either...OnClick="Submit_Click" property of the <asp:Button>, or... btnButton.Click += EventHandler( this.Submit_Click ); in your code behind.
(Make sure you have the correct arguments for the handler - see Button.Click event in the MSDN help for an example)