Hello,

I'm very new to .net so please be patient w/me. I'm using C# in VS2005. I have the following in my login.aspx page for the button

login.aspx
<tr>
<td align="center" colspan="2">
<asp:Button ID="Submitbtn" runat="server" Text="Log In" ValidationGroup="Login1" BackColor="DarkGray" Font-Bold="False" ForeColor="Black"/>
</td>
</tr>


This is the code behind. Somehow when I click on the button, it is not firing the event Submitbtn_click. Can someone please help me? I'm using typed data sets. Thanks in advance...

login.aspx.cs (Code Behind)
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.Security;
using System.Data.SqlClient;
using System.Configuration;
using LoginTableAdapters;

namespace LoginPage
{
publicpartialclassWebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox UserName;
protected System.Web.UI.WebControls.RequiredFieldValidator rvUserValidator;
protected System.Web.UI.WebControls.TextBox Password;
protected System.Web.UI.WebControls.RequiredFieldValidator rvPasswordValidator;
protected System.Web.UI.WebControls.Button Submitbtn;
protected System.Web.UI.WebControls.ValidationSummary Validationsummary1;
protected System.Web.UI.WebControls.Label lblMessage;
protected System.Web.UI.WebControls.Label lblMessage2;
private void Page_Load(object sender, System.EventArgs e)
{

}

private void InitializeComponent()
{
this.Submitbtn.Click += new System.EventHandler(this.Submitbtn_Click);
this.Load += new System.EventHandler(this.Page_Load);
}

private void Submitbtn_Click(object sender, System.EventArgs e)
{
if (Page.IsValid)
{
// Create the tblUserTableAdapter
tblUserTableAdapter LoginAdapter = new tblUserTableAdapter();
// Get account information based on parameters entered
Login.tblUserDataTable Accounts =
LoginAdapter.GetDataBy("user1", "password");
// Bind the order results to the GridView
this.GridView1.DataSource = Accounts;
this.GridView1.DataBind();

}
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}

Thanks,
Kathy

Recommended Answers

All 2 Replies

How do you determine if Page.IsValid is true?

Hello everyone,

I actually got it to work. It used the FindControl method and converted it to a text box.

Kathy

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.