asp:image button is not working

Posted by Kannan1986 under ASP.NET on 2/6/2010 | Views : 3439 | Status : [Member] | Replies : 3
asp:image button is not working

<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Images/button_search.gif" OnClick="ImageButton1_Click" />

protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
SqlCommand myCommand = new SqlCommand("sp_login", sqlcon);

myCommand.CommandType = CommandType.StoredProcedure;

SqlParameter username = new SqlParameter("@username", SqlDbType.VarChar, 250);

username.Value = txtusername.Text;

myCommand.Parameters.Add(username);

SqlParameter password = new SqlParameter("@password", SqlDbType.VarChar, 250);

password.Value = txtpassword.Text;

myCommand.Parameters.Add(password);


dr = myCommand.ExecuteReader();

if (dr.Read())
{
Response.Redirect("Permanentlogin.aspx");
}

sqlcon.Close();
}




Responses

Posted by: Neeks on: 2/6/2010 [Member] Bronze

Up
0
Down
Which error are you getting?

Try to put debugger at the event.

Is the event get fired?

Kannan1986, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Abhi2434 on: 2/7/2010 [Member] [Microsoft_MVP] [MVP] Silver

Up
0
Down
Nothing wrong with the code. Can you please let me know what error you are getting?

Does it actually call the method?


www.abhisheksur.com

Kannan1986, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Mkkanth on: 8/6/2010 [Member] Starter

Up
0
Down
put CausesValidation="false" for the image button

Kannan1986, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response