Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In the <code>Repeater</code> you used databinding syntax (<code>&lt;%# ... %&gt;</code>), but that doesn't apply in this case. You <em>should</em> be able to set the attribute like this:</p> <pre><code>data-valmsg-for='&lt;%= TextBox1.ClientID %&gt;' </code></pre> <p>Why are you adding custom attributes to the validators in the first place though, if you don't mind me asking? What purpose does it serve that can't be achieved through other means?</p> <p><strong>EDIT</strong></p> <p>Have you considered building your list of control IDs in code-behind beforehand, and storing it somewhere? Could something like this be a starting point?:</p> <pre><code>var controlList = Page.Validators.OfType&lt;BaseValidator&gt;() .Select(v =&gt; Page.FindControl(v.ControlToValidate).ClientID).ToList(); </code></pre> <p><strong>EDIT</strong></p> <p>Expanding on that idea, you can serialize the list to JSON using the <code>JavaScriptSerializer</code> (<code>System.Web.Script.Serialization</code>):</p> <pre><code>//initialize the javascript serializer var serializer = new JavaScriptSerializer(); //retrieve all of the validators on the page and store the client ids in a list var controlList = Page.Validators.OfType&lt;BaseValidator&gt;() .Select(v =&gt; Page.FindControl(v.ControlToValidate).ClientID).ToList(); //serialize the control id list and register the script block on the page Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "data", string.Format("var data = {0}", serializer.Serialize(controlList)), true); </code></pre> <p>Depending on how complex the form is, you may need to create a recursive function to find all of the controls, but hopefully this demonstrates the concept.</p>
    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. This table or related slice is empty.
    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