In the ASPX, you can generate your client script with server controls in the 
form of
<script>
document.getElementById("<%=ddlComponents.ClientID%>");
</script>>


[Description: Description: C:\Users\Brian\Pictures\EXD Logos\Extelligent logo 
no text.jpg]Ishai Sagi | Solutions Architect
0488 789 786 | [email protected]<mailto:[email protected]> | 
www.sharepoint-tips.com<http://www.sharepoint-tips.com/> | 
@ishaisagi<http://twitter.com/ishaisagi> | MVP 
Profile<https://mvp.support.microsoft.com/profile/Ishai>

From: [email protected] [mailto:[email protected]] On Behalf Of 
Web Admin
Sent: Wednesday, 3 July 2013 3:33 PM
To: ozMOSS
Subject: Re: Dropdownlist and masterpage gibberish

You can also specify a static ID for the field in your aspx and use code behind 
to affect its behaviour, which I'd recommend.

Using jQuery wildcards like the one above can become very problematic if other 
controls exist or need to be added later.

If you HAVE to use jQuery then I would lock-down the order of the control(s) 
within the page rendering structure and target it using pseudo selectors such 
nth-child.

Regards,

Paul

On 3 July 2013 13:27, Ajay <[email protected]<mailto:[email protected]>> 
wrote:
Thanks Guys,

$("[id$=ddlComponents]") looks great... Will try this soon... big relief

Cheers
Ajay

On Wed, Jul 3, 2013 at 2:44 PM, Matthew Cosier 
<[email protected]<mailto:[email protected]>> wrote:

That "gibberish" is the construction of the client ID for the element which is 
constructed using the hierarchy of the control on the page.



You need to be less specific with your jQuery selector.  You can do this using 
wildcard selectors:

$("[id$=ddlComponents]")



This will select the element where the id ends with ddlComponents, that way if 
you change the location of this control on your page, your script will still 
function.



Cheers,



Matthew Cosier | Hazaa Pty Ltd |  m: +61 428 322 
904<tel:%2B61%20428%20322%20904> | e: 
[email protected]<mailto:[email protected]> | w: 
http://www.hazaa.com.au<http://www.hazaa.com.au/>

On Wed, Jul 3, 2013 at 12:16 PM, Ajay 
<[email protected]<mailto:[email protected]>> wrote:
Hi Guys,
I am creating a custom user control in MOSS 2007 to save some values to 
database.
I am seeing the tags have changed because of masterpage..and affected Jquery 
code
Dropdown id was ddlComponents, it changed to
#ctl00_m_g_97d0d488_aa17_4761_a330_12496d50c779_ctl00_ddlComponents
I have changed this and Jquery is working fine...

When we deploy to Test environment, will this gibberish - 
ctl00_m_g_97d0d488_aa17_4761_a330_12496d50c779_ctl00_- change again...


Cheers
A



_______________________________________________
ozmoss mailing list
[email protected]<mailto:[email protected]>
http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss


_______________________________________________
ozmoss mailing list
[email protected]<mailto:[email protected]>
http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss


_______________________________________________
ozmoss mailing list
[email protected]<mailto:[email protected]>
http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss

<<inline: image001.jpg>>

<<inline: image002.jpg>>

_______________________________________________
ozmoss mailing list
[email protected]
http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss

Reply via email to