Welcome to Dream.In.Code
Getting C# Help is Easy!

Join 136,245 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 2,209 people online right now. Registration is fast and FREE... Join Now!




Accessing a code behind function on keypress event

 
Reply to this topicStart new topic

Accessing a code behind function on keypress event, Accessing a code behind function on keypress event

penn.nila
13 Oct, 2008 - 09:21 PM
Post #1

New D.I.C Head
*

Joined: 13 Oct, 2008
Posts: 2

I havent wriiten an code. i just wanted to know how to call a codebehind function on keypress even in c#. is it possible to call a server side function when a key in? Please give me the code snippets example of any text box keypress event. syntaxt of the event call.

This post has been edited by penn.nila: 13 Oct, 2008 - 09:24 PM
User is offlineProfile CardPM
+Quote Post

gabehabe
RE: Accessing A Code Behind Function On Keypress Event
14 Oct, 2008 - 01:59 AM
Post #2

Donkey DIC
Group Icon

Joined: 6 Feb, 2008
Posts: 5,522



Thanked: 96 times
Dream Kudos: 2650
Expert In: ruling the world.

My Contributions
If you just double click it in design view it will automatically add a method called void TextBox1_TextChanged()

That's the function that you should edit~

smile.gif

(Note that if you want to do it yourself, you can)
this.textBox1.TextChanged += new System.EventHandler(myEventHandler);


Then, your event handler function should look like this:
csharp
void myEventHandler(object sender, EventArgs e) {
// do stuff here
}

Hope this helps smile.gif
User is offlineProfile CardPM
+Quote Post

penn.nila
RE: Accessing A Code Behind Function On Keypress Event
14 Oct, 2008 - 02:23 AM
Post #3

New D.I.C Head
*

Joined: 13 Oct, 2008
Posts: 2

Hey dude!

Thanks a lot for the swift reply.

Cheers, GBU. smile.gif

QUOTE(gabehabe @ 14 Oct, 2008 - 02:59 AM) *

If you just double click it in design view it will automatically add a method called void TextBox1_TextChanged()

That's the function that you should edit~

smile.gif

(Note that if you want to do it yourself, you can)
this.textBox1.TextChanged += new System.EventHandler(myEventHandler);


Then, your event handler function should look like this:
csharp
void myEventHandler(object sender, EventArgs e) {
// do stuff here
}

Hope this helps smile.gif


User is offlineProfile CardPM
+Quote Post

eclipsed4utoo
RE: Accessing A Code Behind Function On Keypress Event
14 Oct, 2008 - 04:38 AM
Post #4

D.I.C Regular
Group Icon

Joined: 21 Mar, 2008
Posts: 353



Thanked: 19 times
Dream Kudos: 25
My Contributions
I don't think that is what you want to do. since you said "server side function", I will assume this is in ASP.Net(you probably should have posted this in the ASP.Net forum). calling a server side function will cause you to do a postback. doing a postback on every keypress is HIGHLY inefficient.

you will want to use javascript.
User is offlineProfile CardPM
+Quote Post

gabehabe
RE: Accessing A Code Behind Function On Keypress Event
14 Oct, 2008 - 06:06 AM
Post #5

Donkey DIC
Group Icon

Joined: 6 Feb, 2008
Posts: 5,522



Thanked: 96 times
Dream Kudos: 2650
Expert In: ruling the world.

My Contributions
Didn't see that bit blush.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 03:49AM

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month