<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: jQuery Selectors and ASP.Net Controls</title>
	<atom:link href="http://fooberry.com/2009/01/07/jquery-selectors-and-aspnet-controls/feed/" rel="self" type="application/rss+xml" />
	<link>http://fooberry.com/2009/01/07/jquery-selectors-and-aspnet-controls/</link>
	<description>Sweetness Without Context</description>
	<lastBuildDate>Wed, 10 Mar 2010 22:45:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: mark</title>
		<link>http://fooberry.com/2009/01/07/jquery-selectors-and-aspnet-controls/comment-page-1/#comment-7798</link>
		<dc:creator>mark</dc:creator>
		<pubDate>Thu, 14 Jan 2010 16:05:14 +0000</pubDate>
		<guid isPermaLink="false">http://fooberry.com/2009/01/07/jquery-selectors-and-aspnet-controls/#comment-7798</guid>
		<description>@zika I don&#039;t start my controls with &quot;_&quot;. The naming container is throwing that in for me. I used to prefix with control names, but found suffixing with the entire control name is more readable for me. The problem I had was trying to prefix a slider control, or any other custom control? sldDegreesOfRotation? I like DegreesOfRotationSlider. Also, I like that MyTextbox, MyLabel, MyRequiredFieldValidator all show up next to each other in the intellisense.

Even in your example, &quot;_txtMy&quot; would still work, but you&#039;re right. You&#039;re less likely to run into &quot;txtFirsttxtName&quot; this way.</description>
		<content:encoded><![CDATA[<p>@zika I don&#8217;t start my controls with &#8220;_&#8221;. The naming container is throwing that in for me. I used to prefix with control names, but found suffixing with the entire control name is more readable for me. The problem I had was trying to prefix a slider control, or any other custom control? sldDegreesOfRotation? I like DegreesOfRotationSlider. Also, I like that MyTextbox, MyLabel, MyRequiredFieldValidator all show up next to each other in the intellisense.</p>
<p>Even in your example, &#8220;_txtMy&#8221; would still work, but you&#8217;re right. You&#8217;re less likely to run into &#8220;txtFirsttxtName&#8221; this way.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zika</title>
		<link>http://fooberry.com/2009/01/07/jquery-selectors-and-aspnet-controls/comment-page-1/#comment-7797</link>
		<dc:creator>zika</dc:creator>
		<pubDate>Thu, 14 Jan 2010 15:56:35 +0000</pubDate>
		<guid isPermaLink="false">http://fooberry.com/2009/01/07/jquery-selectors-and-aspnet-controls/#comment-7797</guid>
		<description>Instead of starting your conrols with _ , and having &quot;_myTextBox&quot;, you may try &quot;txtMy&quot; and in that situation txt prefix will be the same as undescore _.

nice article by the way.</description>
		<content:encoded><![CDATA[<p>Instead of starting your conrols with _ , and having &#8220;_myTextBox&#8221;, you may try &#8220;txtMy&#8221; and in that situation txt prefix will be the same as undescore _.</p>
<p>nice article by the way.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gnoter</title>
		<link>http://fooberry.com/2009/01/07/jquery-selectors-and-aspnet-controls/comment-page-1/#comment-6031</link>
		<dc:creator>gnoter</dc:creator>
		<pubDate>Thu, 10 Sep 2009 19:07:43 +0000</pubDate>
		<guid isPermaLink="false">http://fooberry.com/2009/01/07/jquery-selectors-and-aspnet-controls/#comment-6031</guid>
		<description>So, got it working.

I had a site master page referencing jquery, then a sub-master, then a default.aspx.  didn&#039;t work; &quot;Object expected&quot; errors.

Added referenc jquery in the sub-master; everything works. 
two things learned:
1) got a major clue on jQuery API (thk U mark!)
2) the a web form&#039;s master page needs to have a reference to jQuery, not the master&#039;s master (if such is the case in your website).</description>
		<content:encoded><![CDATA[<p>So, got it working.</p>
<p>I had a site master page referencing jquery, then a sub-master, then a default.aspx.  didn&#8217;t work; &#8220;Object expected&#8221; errors.</p>
<p>Added referenc jquery in the sub-master; everything works.<br />
two things learned:<br />
1) got a major clue on jQuery API (thk U mark!)<br />
2) the a web form&#8217;s master page needs to have a reference to jQuery, not the master&#8217;s master (if such is the case in your website).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mark</title>
		<link>http://fooberry.com/2009/01/07/jquery-selectors-and-aspnet-controls/comment-page-1/#comment-6029</link>
		<dc:creator>mark</dc:creator>
		<pubDate>Thu, 10 Sep 2009 18:43:34 +0000</pubDate>
		<guid isPermaLink="false">http://fooberry.com/2009/01/07/jquery-selectors-and-aspnet-controls/#comment-6029</guid>
		<description>@gnoter Instead of doing .text, you need to call the jQuery API method .text(&quot;foo&quot;) See http://docs.jquery.com/Attributes/text#val

Too keep it straight in my head, I usually prefix my variable names with $ so I know it is a jQuery object and _not_ a DOM object. 

var $myDiv = $(&quot;#divTest&quot;);
var $myTextbox = $(&quot;input[id$=&#039;txtTest&#039;]&quot;);

It is more obvious to me that I need to call methods on the jQuery API.

$myDiv.text($myTextbox.val());

All the calls off the jQuery objects are all from the API. http://docs.jquery.com/ is your best friend.</description>
		<content:encoded><![CDATA[<p>@gnoter Instead of doing .text, you need to call the jQuery API method .text(&#8220;foo&#8221;) See <a href="http://docs.jquery.com/Attributes/text#val" rel="nofollow">http://docs.jquery.com/Attributes/text#val</a></p>
<p>Too keep it straight in my head, I usually prefix my variable names with $ so I know it is a jQuery object and _not_ a DOM object. </p>
<p>var $myDiv = $(&#8220;#divTest&#8221;);<br />
var $myTextbox = $(&#8220;input[id$='txtTest']&#8220;);</p>
<p>It is more obvious to me that I need to call methods on the jQuery API.</p>
<p>$myDiv.text($myTextbox.val());</p>
<p>All the calls off the jQuery objects are all from the API. <a href="http://docs.jquery.com/" rel="nofollow">http://docs.jquery.com/</a> is your best friend.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gnoter</title>
		<link>http://fooberry.com/2009/01/07/jquery-selectors-and-aspnet-controls/comment-page-1/#comment-6028</link>
		<dc:creator>gnoter</dc:creator>
		<pubDate>Thu, 10 Sep 2009 18:27:37 +0000</pubDate>
		<guid isPermaLink="false">http://fooberry.com/2009/01/07/jquery-selectors-and-aspnet-controls/#comment-6028</guid>
		<description>2 items:
1) Wow, you reply fast, thx, truly.
2) all I get is &quot;object expected&quot; with either of these js:

FYI ~ Since I give all my controls a unique ID (and I don&#039;t use js yet on gridview controls, I&#039;m gonna avoid using the underscore (for the time being).


$(&quot;input[ID$=&#039;txtTest&#039;]&quot;);
$(&quot;input[ID$=&#039;txtTest&#039;]&quot;).text;

One would assume I need to do something other than merely referencing it. So, tried all these and they fail with &quot;object expected&quot;:

$(&quot;divTest&quot;).text = $(&quot;input[ID$=&#039;txtTest&#039;]&quot;).text;
$(&quot;#divTest&quot;).text = $(&quot;input[ID$=&#039;txtTest&#039;]&quot;).text;
$(&quot;.divTest&quot;).text = $(&quot;input[ID$=&#039;txtTest&#039;]&quot;).text;
$(&quot;input[ID$=&#039;divTest&#039;]&quot;).text = $(&quot;input[ID$=&#039;txtTest&#039;]&quot;).text;

As already noted: I&#039;m clueless in the northwest.  One would think it would (and should) &#039;just work&#039; .. ?!</description>
		<content:encoded><![CDATA[<p>2 items:<br />
1) Wow, you reply fast, thx, truly.<br />
2) all I get is &#8220;object expected&#8221; with either of these js:</p>
<p>FYI ~ Since I give all my controls a unique ID (and I don&#8217;t use js yet on gridview controls, I&#8217;m gonna avoid using the underscore (for the time being).</p>
<p>$(&#8220;input[ID$='txtTest']&#8220;);<br />
$(&#8220;input[ID$='txtTest']&#8220;).text;</p>
<p>One would assume I need to do something other than merely referencing it. So, tried all these and they fail with &#8220;object expected&#8221;:</p>
<p>$(&#8220;divTest&#8221;).text = $(&#8220;input[ID$='txtTest']&#8220;).text;<br />
$(&#8220;#divTest&#8221;).text = $(&#8220;input[ID$='txtTest']&#8220;).text;<br />
$(&#8220;.divTest&#8221;).text = $(&#8220;input[ID$='txtTest']&#8220;).text;<br />
$(&#8220;input[ID$='divTest']&#8220;).text = $(&#8220;input[ID$='txtTest']&#8220;).text;</p>
<p>As already noted: I&#8217;m clueless in the northwest.  One would think it would (and should) &#8216;just work&#8217; .. ?!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mark</title>
		<link>http://fooberry.com/2009/01/07/jquery-selectors-and-aspnet-controls/comment-page-1/#comment-6027</link>
		<dc:creator>mark</dc:creator>
		<pubDate>Thu, 10 Sep 2009 18:20:19 +0000</pubDate>
		<guid isPermaLink="false">http://fooberry.com/2009/01/07/jquery-selectors-and-aspnet-controls/#comment-6027</guid>
		<description>@gnoter Also, keep in mind that it doesn&#039;t return the Input DOM object, but rather a jQuery set. You&#039;ll need to operate on it using the jQuery API or get a single object from the set. 

For example,  you won&#039;t be able to do myTextBox.value, you&#039;ll need to do myTextbox.Val(). See http://docs.jquery.com/Attributes/val</description>
		<content:encoded><![CDATA[<p>@gnoter Also, keep in mind that it doesn&#8217;t return the Input DOM object, but rather a jQuery set. You&#8217;ll need to operate on it using the jQuery API or get a single object from the set. </p>
<p>For example,  you won&#8217;t be able to do myTextBox.value, you&#8217;ll need to do myTextbox.Val(). See <a href="http://docs.jquery.com/Attributes/val" rel="nofollow">http://docs.jquery.com/Attributes/val</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gnoter</title>
		<link>http://fooberry.com/2009/01/07/jquery-selectors-and-aspnet-controls/comment-page-1/#comment-6026</link>
		<dc:creator>gnoter</dc:creator>
		<pubDate>Thu, 10 Sep 2009 18:15:13 +0000</pubDate>
		<guid isPermaLink="false">http://fooberry.com/2009/01/07/jquery-selectors-and-aspnet-controls/#comment-6026</guid>
		<description>corrected function (sorry &#039;bout that, I was trying various renditions and copy/pasted a wrong version):

function SetLabel() {
//var sourceID = $(”#lblTest”);
//var targetID = $(”#txtTest”);
var a = “breakpoint”;
var myDiv = $get(”divTest”);
var myTextbox = $get(”&quot;);
myDiv.innerHTML = myTextbox.value;
}</description>
		<content:encoded><![CDATA[<p>corrected function (sorry &#8217;bout that, I was trying various renditions and copy/pasted a wrong version):</p>
<p>function SetLabel() {<br />
//var sourceID = $(”#lblTest”);<br />
//var targetID = $(”#txtTest”);<br />
var a = “breakpoint”;<br />
var myDiv = $get(”divTest”);<br />
var myTextbox = $get(”&#8221;);<br />
myDiv.innerHTML = myTextbox.value;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mark</title>
		<link>http://fooberry.com/2009/01/07/jquery-selectors-and-aspnet-controls/comment-page-1/#comment-6025</link>
		<dc:creator>mark</dc:creator>
		<pubDate>Thu, 10 Sep 2009 18:13:47 +0000</pubDate>
		<guid isPermaLink="false">http://fooberry.com/2009/01/07/jquery-selectors-and-aspnet-controls/#comment-6025</guid>
		<description>@gnoter Sorry about that. There was a typo in the example code. The jQuery selector would look like this:

$(&quot;input[ID$=&#039;_txtTest&#039;]&quot;);

This would find every HTML Input element that has an ID that ends with &quot;_txtTest&quot;. Hopefully there is only one, but if there are more, it will find all of them. You&#039;ll either need to be more specific or give it a reference point.</description>
		<content:encoded><![CDATA[<p>@gnoter Sorry about that. There was a typo in the example code. The jQuery selector would look like this:</p>
<p>$(&#8220;input[ID$='_txtTest']&#8220;);</p>
<p>This would find every HTML Input element that has an ID that ends with &#8220;_txtTest&#8221;. Hopefully there is only one, but if there are more, it will find all of them. You&#8217;ll either need to be more specific or give it a reference point.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gnoter</title>
		<link>http://fooberry.com/2009/01/07/jquery-selectors-and-aspnet-controls/comment-page-1/#comment-6023</link>
		<dc:creator>gnoter</dc:creator>
		<pubDate>Thu, 10 Sep 2009 18:09:20 +0000</pubDate>
		<guid isPermaLink="false">http://fooberry.com/2009/01/07/jquery-selectors-and-aspnet-controls/#comment-6023</guid>
		<description>My controls didn&#039;t post cuz they have greater-than and less-than; here&#039;s another go; replace brackets with greater- &amp; less-thans:


My control:
[div id=&quot;divTest&quot;]
  This is a test.
[/div]
[asp:TextBox ID=&quot;txtTest&quot; runat=&quot;server&quot; Text=&quot;Changed to this new value #2.&quot; /]
[asp:Button ID=&quot;btnTest&quot; runat=&quot;server&quot; Text=&quot;Update Label&quot; CausesValidation=&quot;false&quot; OnClientClick=&quot;return SetLabel();&quot; /]</description>
		<content:encoded><![CDATA[<p>My controls didn&#8217;t post cuz they have greater-than and less-than; here&#8217;s another go; replace brackets with greater- &amp; less-thans:</p>
<p>My control:<br />
[div id="divTest"]<br />
  This is a test.<br />
[/div]<br />
[asp:TextBox ID="txtTest" runat="server" Text="Changed to this new value #2." /]<br />
[asp:Button ID="btnTest" runat="server" Text="Update Label" CausesValidation="false" OnClientClick="return SetLabel();" /]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gnoter</title>
		<link>http://fooberry.com/2009/01/07/jquery-selectors-and-aspnet-controls/comment-page-1/#comment-6022</link>
		<dc:creator>gnoter</dc:creator>
		<pubDate>Thu, 10 Sep 2009 18:06:13 +0000</pubDate>
		<guid isPermaLink="false">http://fooberry.com/2009/01/07/jquery-selectors-and-aspnet-controls/#comment-6022</guid>
		<description>So, here we are in Sept. &#039;09.  I still can&#039;t get a reference to ASP.NET controls in javascript with jQuery.

My control:

  This is a test.



=====
All the js function SetLabel() does is change the div to the value in the text box.
This is the *ONLY* method that works:

  function SetLabel() {
    //var sourceID = $(&quot;#lblTest&quot;);
    //var targetID = $(&quot;#txtTest&quot;);

    var a = &quot;breakpoint&quot;;
    var myDiv = $get(&quot;divTest&quot;).text;
    var myTextbox = $get(&quot;&quot;);
    myDiv.innerHTML = myTextbox.value;
}

===========
C&#039;mon, people; with the above stuff, I get NO access to the jQuery features for these objects.

Your method of using the underscore and then using the EndsWith (having changed the ID of my textbox control to &quot;_txtTest&quot;) would be:

$(&quot;input[ID$=&#039;_txtTest&#039;]);

==&gt; Where is the ending double-quote?
All I get is &quot;unterminated string constant&quot; in VS2008 javascript.
------
At this juncture, I have not been able to successfully employ jQuery after nearly 2 weeks of research, reading, trying this, trying that.  All I freakin&#039; wanna do is take a stupid textbox and use it&#039;s value to change the value of a div area.
Y&#039;know, start small, then onto larger concepts.
BTW: WinXPPro_SP3, VS2008_SP1, ASP.Net 3.5, jQuery 1.3.2 w/ the vsdoc file, no master page, no fancy extra plugins, just a basic website with Default.aspx.
====
I gotta admit that I guess I&#039;m *totally clueless&quot; in any of this.</description>
		<content:encoded><![CDATA[<p>So, here we are in Sept. &#8216;09.  I still can&#8217;t get a reference to ASP.NET controls in javascript with jQuery.</p>
<p>My control:</p>
<p>  This is a test.</p>
<p>=====<br />
All the js function SetLabel() does is change the div to the value in the text box.<br />
This is the *ONLY* method that works:</p>
<p>  function SetLabel() {<br />
    //var sourceID = $(&#8220;#lblTest&#8221;);<br />
    //var targetID = $(&#8220;#txtTest&#8221;);</p>
<p>    var a = &#8220;breakpoint&#8221;;<br />
    var myDiv = $get(&#8220;divTest&#8221;).text;<br />
    var myTextbox = $get(&#8220;&#8221;);<br />
    myDiv.innerHTML = myTextbox.value;<br />
}</p>
<p>===========<br />
C&#8217;mon, people; with the above stuff, I get NO access to the jQuery features for these objects.</p>
<p>Your method of using the underscore and then using the EndsWith (having changed the ID of my textbox control to &#8220;_txtTest&#8221;) would be:</p>
<p>$(&#8220;input[ID$='_txtTest']);</p>
<p>==&gt; Where is the ending double-quote?<br />
All I get is &#8220;unterminated string constant&#8221; in VS2008 javascript.<br />
&#8212;&#8212;<br />
At this juncture, I have not been able to successfully employ jQuery after nearly 2 weeks of research, reading, trying this, trying that.  All I freakin&#8217; wanna do is take a stupid textbox and use it&#8217;s value to change the value of a div area.<br />
Y&#8217;know, start small, then onto larger concepts.<br />
BTW: WinXPPro_SP3, VS2008_SP1, ASP.Net 3.5, jQuery 1.3.2 w/ the vsdoc file, no master page, no fancy extra plugins, just a basic website with Default.aspx.<br />
====<br />
I gotta admit that I guess I&#8217;m *totally clueless&#8221; in any of this.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
