Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OnFocus server side event for textbox in datagrid

Status
Not open for further replies.

minckle79

Programmer
Jul 12, 2011
2
GB
I have a datagrid containing multiple rows / columns, with template column, each cell contains a textbox.

I need to be able to track when a textbox gets focus and which textbox it is?
so when i click on a textbox i need to run a server side event. There doesn t seem to be a standard event so was wondering if i need to add javascript to kick of the event.

theres a onTextChanged Event but no onFocus Event

any ideas would be really helpful
 
You will have to attach a call to a js function for the textbox. You can do this using the RowDataBound event of the grid. Use FindControl() to find the text box, attach an onfocus event to the textbox. If you need the id of the textbox, pass in ClientID of the textbox to your function.
 
do you really want a full webforms postback each time an input gets focus? this will make for a terrible user experience. A better approach would be to simply use js, ajax & json. have a simple generic handler or web server handle the request and serialize objects to json for transmission.
the webform page wouldn't need to know about any of this.

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
I didn't realize you needed server code to run each time. As Jason says, not a good idea. Use his suggestions.
 
thanks guys, ill start reading up on ajax & json
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top