Click here to Skip to main content
15,889,909 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi,

I have an add user page and the buttons on it just restart the website to the login page.

button defined in form:
ASP.NET
<asp:Button ID="btnAddUser" runat="server" onclick="btnAddUser_Click" Text="Add User" />


From the designer double clicked the button, and it opened in the .aspx.cs file
C#
protected void btnAddUser_Click(object sender, EventArgs e)
        {
        }


After putting in the code to write a new user to SQL, it just resets to the main page. doesn't go trough the c# code. (tried F11 step line by line the function never gets called).

As far as i can see i've done nothing different on the form from the login page to the add user page...

At a loss, and the professional guy who's training me couldn't figure it either and is now gone for the weekend....

need some help to finish this and get onto the next problem

thanks,

BBB
Posted
Updated 24-Aug-12 9:52am
v2

So, what you are saying is that the btnAddUser_Click event is not firing though you have clicked the button.

Is the page_load firing when you click the button? If answer is No, you have a problem with class name.

public partial class testsample: System.Web.UI.Page

<![CDATA[<%@ Page Language="C#" AutoEventWireup="true" CodeFile="testsample.aspx.cs" Inherits="testsample" %>]]>


So the testsample must match so that the right class is invoked. This is sometimes a problem coping code with duplicate name.

Ok, now if your page_load fires, check
Page.IsPostBack
It should be true when you clicked the button.

Debug your code and see, if there is any Response.End or anaything which obstructs to go into the button_click event code.

Hope your problem will be solved.

cheers
 
Share this answer
 
Comments
BBBwex 24-Aug-12 12:51pm    
ah... found it probably.... page.IsPostBack = false...
after Page_load fnct I gave one of the fields the value of Page.IsPostBack

I'll have a look and see if i can figure this out myself before checking here again
BBBwex 24-Aug-12 13:14pm    
Got it sorted. your reply started a different train of thought and research which let me to look at the forms and the solution.

Cheers, gave your reply 4*
Check any postbackurl is given for the button
 
Share this answer
 
Comments
BBBwex 24-Aug-12 12:29pm    
Nope, just standard settings when inserted into form from the toolbox

Gave it an (ID), text for the button.

Then doubleclicked it to edit the c# code to add the userinfo to SQL, and it just wont call it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900