Retrieve Textbox Value From Datagrid

B

Bryan

Hello:

I need to retrieve the value of a textbox control in a asp.net datagrid
using Javascript. Can anybody help out. I believe the control clientID needs
to be passed client side so the javascript can reference. Any idea how.
Thanks
 
M

Martin Honnen

Bryan wrote:

I need to retrieve the value of a textbox control in a asp.net datagrid
using Javascript. Can anybody help out. I believe the control clientID needs
to be passed client side so the javascript can reference. Any idea how.


If you have an .aspx page then that has a
<form runat="server">
and in that form you have the datagrid. Make sure you give the form
element a name e.g.
<form name="formName" runat="server">
and then you can access
document.forms.formName.elements.textboxName.value
If the textboxes in your data grid do not have a name then you could go
by the index e.g.
document.forms.formName.elements[index].value

Or in newer browsers you can use the id of the textbox, you could then
use RegisterClientScriptBlock in ASP.NET to create a global, client-side
variable to store the id.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top