locked
problem with rendering of asp.net RadioButton onkeypress event? RRS feed

  • Question

  • User-1800127182 posted

    I have some radiobuttons that cause a post.  Before going to the server side, the radio buttons has the onclick event in order to do some client side validation.

    but the problem is we have to support the secion 508, for we are using the Sort site tool according to that tool every onckick event must have onkeypress event .  When I use the following code:

    <asp:RadioButton ID="rbPublic" runat="server" Text="Public Inquiry" Checked="true" GroupName="1" AutoPostBack="true" onkeypress="" onClick="" />

    the html is rendered as follows:

    <span onkeypress=""><input id="ctl00_ContentPlaceHolder1_rbPublic" type="radio" name="ctl00$ContentPlaceHolder1$1" value="rbPublic" checked="checked" /><label for="ctl00_ContentPlaceHolder1_rbPublic" onclick="">Public Inquiry</label></span>

    Since the the onkeypress event is put in a <span> tag,  Somehow I need to get the following html:

    <input id="ctl00_ContentPlaceHolder1_rbPublic" type="radio" name="ctl00$ContentPlaceHolder1$1" value="rbPublic" checked="checked" onkeypress="" onclick="" /> 

    Is there a way to do this?

    Thanks,

    Burepalli V S Rao.

    Monday, March 28, 2011 10:13 PM

Answers

  • User1182340765 posted

    I don't know if there is a better solution. But if you couldn't figure out, you can create a custom server control which inherits RadionButton and override its RenderBeginTag method to render the onkeypress inside the <input> tag.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 28, 2011 10:46 PM