Re: Dropdownlist and masterpage gibberish

2013-07-02 Thread Matthew Cosier
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* | e: *matt*@*
hazaa.com.au m...@hazaa.com.au* | w: *http://www.hazaa.com.au


On Wed, Jul 3, 2013 at 12:16 PM, Ajay akhanna...@gmail.com 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
 ozmoss@ozmoss.com
 http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss


___
ozmoss mailing list
ozmoss@ozmoss.com
http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss


RE: Dropdownlist and masterpage gibberish

2013-07-02 Thread Nigel Witherdin
Yes - the control id is generated by sharepoint, consisting of the Guid 
assigned to the web part (I think) and some other details. So it will change 
between environments, site collections and even pages that the control is 
deployed to.
The best bet is to find another way to refer to your control in the jQuery, for 
example by class, or by using a selection pattern where you select a div 
containing the dropdown, then the next 'select'.
e.g. 
var dropDownCtrl = jQuery(select.drpDownClassName)
or
var dropdownCtrl = jQuery(div.divsClassName  select)
From: akhanna...@gmail.com
Date: Wed, 3 Jul 2013 14:16:24 +1200
Subject: Dropdownlist and masterpage gibberish
To: ozmoss@ozmoss.com

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
ozmoss@ozmoss.com
http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss   
  ___
ozmoss mailing list
ozmoss@ozmoss.com
http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss


Re: Dropdownlist and masterpage gibberish

2013-07-02 Thread Ajay
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 cos...@gmail.com 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* | e: *matt*@*
 hazaa.com.au m...@hazaa.com.au* | w: *http://www.hazaa.com.au


 On Wed, Jul 3, 2013 at 12:16 PM, Ajay akhanna...@gmail.com 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
 ozmoss@ozmoss.com
 http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss



 ___
 ozmoss mailing list
 ozmoss@ozmoss.com
 http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss


___
ozmoss mailing list
ozmoss@ozmoss.com
http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss


Re: Dropdownlist and masterpage gibberish

2013-07-02 Thread Web Admin
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 akhanna...@gmail.com 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 cos...@gmail.com 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* | e: *matt*@*
 hazaa.com.au m...@hazaa.com.au* | w: *http://www.hazaa.com.au


 On Wed, Jul 3, 2013 at 12:16 PM, Ajay akhanna...@gmail.com 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
 ozmoss@ozmoss.com
 http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss



 ___
 ozmoss mailing list
 ozmoss@ozmoss.com
 http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss



 ___
 ozmoss mailing list
 ozmoss@ozmoss.com
 http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss


___
ozmoss mailing list
ozmoss@ozmoss.com
http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss