We're attempting to upgrade our site from framework 3.5 to 4.0. Everything appears to be fine server side - My only problem so far is the IDs of a handful of custom controls.
The Controls deceleration looks like:
<div runat="server" id="gglSelectedItemsImage" class="gplSelectedItemsText">None selected</div>
When rendered in 3.5 the control looks like:
<div id="gplCategories_gglSelectedItemsImage" class="gplSelectedItemsText">Some Content</div>
And in 4.0 Like:
<div id="ctl00_ctl00_ctl00_ContentPlaceHolder1_Content_gplCategories_gglSelectedItemsImage" class="gplSelectedItemsText">Some Content</div>
Yo he puesto
<pages clientIDMode="AutoID" controlRenderingCompatibilityVersion="3.5" /> in the web.config so 99.9% of the IDs are correct. The weirdest thing is the 3.5 control looks like it rendering with
clientIDMode="Predictable" rather than the standard 3.5 auto IDs?
Furthermore if I access the controls clientID Server side in 4.0 it appears correct:
Me.gglSelectedItemsImage.ClientID = "gplCategories_gglSelectedItemsImage"
Our site is unfortunately to large to just fix this one error so I need to work out why the control is rendering its ID differently and implement it across the site.
Any idea's you guys have will be very much appreciated.
preguntado el 08 de noviembre de 11 a las 15:11
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
In the second example you're using a master page, which explains why the
ClientID is different. It shouldn't make a difference though if you're referencing the control by
var ctrl = $("#<%=gglSelectedItemsImage.ClientID%>");
You should access the client id's like this in your .ASPX file: