Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>When does the "magic" is done to change asp.net tag to select?</p> </blockquote> <p>Most of "magic" you're wondering about is done by ASP.NET controls, which are designed to generate the markup that is sent to the browser.</p> <p>When a request is received, the application iterates over each control, calling its <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.control.render.aspx" rel="nofollow"><code>Render</code></a> method (inherited from the <code>Control</code> class), which allows each control to generate the markup they represent.</p> <p>Following your example, the <code>DropDownList</code> control generates a <code>&lt;select&gt;</code> tag. As a <code>ListControl</code>, it uses the <code>ListItem</code> controls to create the <code>&lt;option&gt;</code> tags within.</p> <p>Another would be the <code>GridView</code>, which generates a <code>&lt;table&gt;</code> using <code>GridViewRow</code> controls for <code>&lt;tr&gt;</code> and various HTML Controls, such as <code>TableCell</code> for <code>&lt;td&gt;</code> and <code>&lt;th&gt;</code>, to create the rest of the markup.</p> <blockquote> <p>Shoud I use a tags which I see in the source code of a page in a browser or can I ask jQuery about asp.net tags?</p> </blockquote> <p>No, jQuery/JavaScript have no knowledge of server-side control names, only the markup they generate. So, rather than searching for <code>$('DropDownList')</code>, you'd search for <code>$('select')</code>.</p> <blockquote> <p>What is more I can't see my CSS classes names added to asp.net tags. There are some kind of differen CSS class names.</p> </blockquote> <p>By "<em>CSS Names</em>," do you mean IDs? I'm sorry to ask, but <code>CssClass</code> attributes shouldn't change in value from server-side to client-side, just in name -- <code>CssClass</code> to just <code>class</code>.</p> <p>IDs, on the other hand, are prefixed to ensure their uniqueness throughout the page, including a prefix of the MasterPage and ContentPlaceHolder names, if they're used. For this reason, I'd steer away from trying to use IDs to apply CSS to server-side controls, using classes instead.</p> <p>Now, the end of the ID should remain as the ID you gave in server-side, so you should still be able to find the element in jQuery using the <a href="http://api.jquery.com/attribute-ends-with-selector/" rel="nofollow">Attribute Ends With Selector <code>[name$='value']</code></a>:</p> <pre><code># ASP &lt;asp:DropDownList ID="AnyGivenDropDown" runat="server" /&gt; # HTML (generated) &lt;select id="ctl00_PageContents_AnyGivenDropDown"&gt;&lt;/select&gt; # JavaScript $('select[id$="_AnyGivenDropDown"]'); </code></pre> <p>Otherwise, I'd stick to classes to find the controls you're looking for:</p> <pre><code># ASP &lt;asp:DropDownList ID="AnyGivenDropDown" CssClass="anygiven" runat="server" /&gt; # HTML (generated) &lt;select id="ctl00_PageContents_AnyGivenDropDown" class="anygiven"&gt;&lt;/select&gt; # JavaScript $('select.anygiven'); # CSS .anygiven { } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload