Last post Oct 23, 2014 08:19 AM by SeeDosRun
Oct 22, 2014 11:54 AM|SeeDosRun|LINK
Site that uses master pages
In a content page I have a detailsview control containing many controls - textboxes, labels, dropdowns etc.
Detailsview has Template fields with item and edititem templates
I want to access the value of a label within an itemtemplate field.
End Bootstrap Row
Label ID="registrationID" -- THIS IS CONTROL THAT CONTAINS THE VALUE I WANT
. . . .
var regIdText = $('#' + '<%= registrationID.ClientID %>').val();
But I get an error saying registrationID is not declared.
I tried adding a css class to the label and selecting it that way but it failed as well.
Oct 22, 2014 04:29 PM|William Klein|LINK
Becuase the registrationID control is nested within the template you won't be able to access it outside that ItemTemplate.
var regIdText = $('#registrationID').val();
Oct 23, 2014 01:17 AM|Fei Han - MSFT|LINK
Thanks for your post.
ASP.NET allows certain controls to be denoted as naming containers. A naming container serves as a new ID namespace. Any server controls that appear within the naming container have their rendered id value prefixed with the ID of the naming container control.
In this situation, you should visit the page through a browser and view the HTML source to check the id of the Label then get the value according to correct id.
For more information about “Control ID Naming in Content Pages”, you could refer to the below link.
Hope it will be helpful to you.
Oct 23, 2014 08:19 AM|SeeDosRun|LINK
Thanks for you suggestions.
I ended up using
that way I don't have to worry about naming containers.