467,907 Members | 1,095 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,907 developers. It's quick & easy.

How to activate button click event using enter button

hi,

I have designed a web part using VS 2003 (Web control library template). I need to publish that in share point. Its not like drag and drop the things from toolbar. Every thing I need to do in code behind side.

I have a button and text box

Button Id: btnSearch
TextBox id: txtSearch


Button performs search operation. I need to enter a text to be searched and when I click button means the button click event is activated. That is search function is activated and we can view the records in data grid.

What I need is that if I press the enter button inside the text box means the search function need to be done. In other words button click event should be fired and correspondingly data grid should be viewed.

I used key press event but it is not firing.
Here is my button search event…

protected void btnSearch_Click(object sender, System.EventArgs e)

{



SearchText = txtSearch.Text; //getting text to be searched from text box.

fillDataGrid(); //populating data grid..

}

Key press event…..

private void txtSearch_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)

{

if(e.KeyChar == (char) 13)

{

this.btnSearch_Click(sender, new EventArgs());

}

}

can any one say the solution...?

Thanks in advance..
May 11 '07 #1
  • viewed: 1717
Share:

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Philip Townsend | last post: by
5 posts views Thread by Steve | last post: by
6 posts views Thread by Michael Johnson Jr. | last post: by
1 post views Thread by marcelo | last post: by
3 posts views Thread by Imran Aziz | last post: by
2 posts views Thread by carmelo.orlando | last post: by
3 posts views Thread by Robert W. | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.