How to control or override the Client Side Naming of a Server Side Control in ASP.net 3.5?
Is there a way to control the client side name that is assigned to a Server Side Control in ASP.Net 3.5.
I currently the following in an ASP.Net Repeater that just presents a list of a bunch of Yes No Questions.
<asp:RadioButtonList RepeatDirection="Horizontal" CssClass="YesNo" ID="YesNo" runat="server">
<asp:ListItem Value="Yes" Text="Yes" />
<asp:ListItem Value="No" T开发者_C百科ext="No" />
</asp:RadioButtonList>
On the Client Side the following is what is rendered.
<input id="Repeater1_ctl00_YesNo_0" type="radio" value="Yes" name="Repeater1$ctl00$YesNo">
<label for="Repeater1_ctl00_YesNo_0">Yes</label>
I would like to be able to have the Client Side Name of the control be something like
name = <%# DataBinder.Eval(Container.DataItem, "QuestionNumber") %>YesNo
So when the form data is posted I can easily Identify the QuestionNumber and type of Question.
Is there a way to override the naming scheme that asp.net using so instead of seeing Repeater1$ctl00$YesNo I will see 4YesNo when the form is posted?
You can use Control.ClientID Property.
精彩评论