I'm creating a form validation. i have these buttons with on my .cshtml. When the user clicks it, a css class (selected) will be added on it.
<button type="button" ID="btn_100" runat="server" class="selected">100</button>
<button type="button" ID="btn_200" runat="server">200</button>
....
<button type="button" ID="btn_600" runat="server">600</button>
Once the user submits the form, it will be validated and if it fails, it should keep the button class in it or simply keep the button state.
What i'm thinking is to target the button from code behind using its value. Is there a similar like jQuery selector in asp.net that this?
$('button[value="100"]");
Or have a dynamic button variable, like this
btn_(value_selected).Attribute.Add("class","selected");
Any suggestion? TIA!
You can modify the style or anything in code behind.
However, you do have to "find" the control.
So, say you can do this:
note how we can supply a "string" value to get/find the button.
C#
Note that "add" for style is really quite much the same as setting - if you were to say accident add the above style setting two times - it does not cumulate up (so if style setting exists - it is replaced).