Have you tried using jQuery? If you haven't you can find any element on the page by a
selector. So if you want to find a hidden field called hdnField you would do this:
First i have read <tr> from grid. Then i am reading input tag. I have one checkbox and 2 hidden field in input tag. I want to find one hidden field which is emp_id.
Will you please help me.
Thanks in advance
if it help please click on "Mark as Answer" on this post
First i have read <tr> from grid. Then i am reading input tag. I have one checkbox and 2 hidden field in input tag. I want to find one hidden field which is emp_id.
Can you show us some piece of your generated html? jQuery could indeed help you to find what you're after. I suggest you take a look at its selectors:
http://docs.jquery.com/Selectors.
Grz, Kris.
Read my blog | Twitter Interested in Azure, ASP.NET (MVC), jQuery, WCF, EF, MS SQL, ...
Keep the forums clean: report to the moderation team!
Well that piece of JavaScript will return the value of the hidden field. So if you only have one hidden field named that, that piece of code will find it without looping through each row in the table. Make sense?
mamtagupta
Member
328 Points
169 Posts
Re: how to find gridview hidden label value from javascript
Jan 05, 2010 04:27 AM|LINK
hi
i get array. But now how i identify different controls with id
Example If i have two hidden field in array. How can i find one.
Please help me.
Regards
Mamta
mamtagupta
Member
328 Points
169 Posts
Re: how to find gridview hidden label value from javascript
Jan 05, 2010 04:31 AM|LINK
hi
it's not new thread. It's same here i am finding gridview row with tr tag.
Regards
Mamta
malcolms
All-Star
18687 Points
3124 Posts
MVP
Re: how to find gridview hidden label value from javascript
Jan 05, 2010 05:07 AM|LINK
Have you tried using jQuery? If you haven't you can find any element on the page by a selector. So if you want to find a hidden field called hdnField you would do this:
$("#hdnField").val();
That would return the value of the hidden field.
mamtagupta
Member
328 Points
169 Posts
Re: how to find gridview hidden label value from javascript
Jan 05, 2010 05:25 AM|LINK
hi malcolms,
I have hidden field in gridview.
First i have read <tr> from grid. Then i am reading input tag. I have one checkbox and 2 hidden field in input tag. I want to find one hidden field which is emp_id.
Will you please help me.
Thanks in advance
Regards
Mamta
XIII
All-Star
182674 Points
23445 Posts
ASPInsiders
Moderator
MVP
Re: how to find gridview hidden label value from javascript
Jan 05, 2010 05:35 AM|LINK
Hi,
Can you show us some piece of your generated html? jQuery could indeed help you to find what you're after. I suggest you take a look at its selectors: http://docs.jquery.com/Selectors.
Grz, Kris.
Interested in Azure, ASP.NET (MVC), jQuery, WCF, EF, MS SQL, ...
Keep the forums clean: report to the moderation team!
mamtagupta
Member
328 Points
169 Posts
Re: how to find gridview hidden label value from javascript
Jan 05, 2010 06:10 AM|LINK
hi kris,
<TABLE id=ctl00_ContentPlaceHolder1_ctl02_ctl00 style="TABLE-LAYOUT: auto; WIDTH: 100%; empty-cells: show" cellSpacing=0 rules=cols border=1>
<COLGROUP>
<COL>
<COL>
<COL>
<COL>
<COL>
<COL>
<COL>
<COL></COLGROUP>
<THEAD>
<TR>
<TH scope=col UniqueName="TemplateColumn"> </TH>
<TH style="DISPLAY: none" scope=col UniqueName="TemplateColumn1"> </TH>
<TH style="DISPLAY: none" scope=col UniqueName="TemplateColumn2"> </TH>
<TH scope=col UniqueName="TemplateColumn3">Name</TH>
<TH scope=col UniqueName="User Name">User Name</TH>
<TH scope=col UniqueName="Department">Department</TH>
<TH scope=col UniqueName="TemplateColumn4">Email</TH>
<TH scope=col UniqueName="Primary Phone">Primary Phone</TH>
<TH scope=col UniqueName="Status">Status</TH>
<TH scope=col UniqueName="Admin">Admin</TH></TR></THEAD>
<TBODY>
<TR id=ctl00_ContentPlaceHolder1_ctl02_ctl00__0>
<TD>
<INPUT id=ctl00_ContentPlaceHolder1_ctl02_ctl00_ctl04_hgtechchk type=checkbox CHECKED name=ctl00$ContentPlaceHolder1$ctl02$ctl00$ctl04$hgtechchk _rfddecoratedID="_rfdSkinnedctl00_ContentPlaceHolder1_ctl02_ctl00_ctl04_hgtechchk"><LABEL id=_rfdSkinnedctl00_ContentPlaceHolder1_ctl02_ctl00_ctl04_hgtechchk for=ctl00_ContentPlaceHolder1_ctl02_ctl00_ctl04_hgtechchk unselectable="on"> </LABEL>
</TD>
<TD style="DISPLAY: none"><INPUT id=ctl00_ContentPlaceHolder1_ctl02_ctl00_ctl04_hbEmployee_Id type=hidden value=e0d44211-bd49-4a60-8906-26a14d032374 name=ctl00$ContentPlaceHolder1$ctl02$ctl00$ctl04$hbEmployee_Id></TD>
<TD style="DISPLAY: none"><INPUT id=ctl00_ContentPlaceHolder1_ctl02_ctl00_ctl04_hbReport_to type=hidden name=ctl00$ContentPlaceHolder1$ctl02$ctl00$ctl04$hbReport_to></TD>
<TD><A id=ctl00_ContentPlaceHolder1_ctl02_ctl00_ctl04_lnkNameEMPLOYEE_ID onclick=" Done('e0d44211-bd49-4a60-8906-26a14d032374','vikas');" href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$ctl02$ctl00$ctl04$lnkNameEMPLOYEE_ID','')">vikas</A></TD>
<TD>vikas</TD>
<TD> </TD>
<TD><A id=ctl00_ContentPlaceHolder1_ctl02_ctl00_ctl04_lnkEmail href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$ctl02$ctl00$ctl04$lnkEmail','')">mg@yahoo.com</A></TD>
<TD> </TD>
<TD>False</TD>
<TD>False</TD>
</TR>
</TBODY>
</TABLE>
this is grid html. and i want to find
<TD style="DISPLAY: none"><INPUT id=ctl00_ContentPlaceHolder1_ctl02_ctl00_ctl04_hbEmployee_Id type=hidden value=e0d44211-bd49-4a60-8906-26a14d032374 name=ctl00$ContentPlaceHolder1$ctl02$ctl00$ctl04$hbEmployee_Id></TD>
this value 'e0d44211-bd49-4a60-8906-26a14d032374'
Please help me.
Thanks in advance
Regards
Mamta
malcolms
All-Star
18687 Points
3124 Posts
MVP
Re: how to find gridview hidden label value from javascript
Jan 05, 2010 06:32 AM|LINK
Try this jQuery. It will only search for a field that ends with hbEmployee_Id:
$("input[id$=hbEmployee_Id]").val()
The $= section of the selector works well in these scenario's where the id is changed thanks to master pages for example.
mamtagupta
Member
328 Points
169 Posts
Re: how to find gridview hidden label value from javascript
Jan 05, 2010 06:49 AM|LINK
hi malcolms,
i have this javascript method
function CheckOtherIsCheckedByGVID() { var Parent = document.getElementById('ctl00_ContentPlaceHolder1_ctl02'); var itemchk = Parent.getElementsByTagName('TR'); var val_ret=''; for(var i=0;i<itemchk.length;i++) { var itemch=itemchk[i].getElementsByTagName('INPUT'); for(var k=0;k<itemch.length;k++) { if(itemch[k].type=="checkbox") { if(itemch[k].checked) { var emp= itemchk("input[id$=hbEmployee_Id]").val(); alert(emp); } } } } }will you please help because I don't know how can i use this.
Regards
Mamta
malcolms
All-Star
18687 Points
3124 Posts
MVP
Re: how to find gridview hidden label value from javascript
Jan 05, 2010 07:21 AM|LINK
Well that piece of JavaScript will return the value of the hidden field. So if you only have one hidden field named that, that piece of code will find it without looping through each row in the table. Make sense?
mamtagupta
Member
328 Points
169 Posts
Re: how to find gridview hidden label value from javascript
Jan 05, 2010 07:25 AM|LINK
hi malcolms
i have multiple rows and multiple hidden fields that why i have problem to find hidden field
Regards
Mamta