0

I have a radiobutton column in a gridview, inside many nested asp tables. I want radios enable two buttons upon click. so I added this the following function an javascript but it cannot find my controls although I turned ClientIDMode="Static" for those buttons. It returns null.

<asp:GridView ID="gridView_stLists" runat="server" AutoGenerateColumns="False" CellPadding="3"
                                                    BorderStyle="NotSet" CssClass="table_layout" Width="500">
                                                    <RowStyle CssClass="table_body" />
                                                    <Columns>
                                                        <asp:TemplateField HeaderStyle-Width="20">
                                                            <ItemTemplate>
                                                                <input name="radioBtn_res" type="radio" value='<%# Eval("uri") %>' onclick="rdBtn_onClick()" />
                                                            </ItemTemplate>

<script language="javascript" type="text/javascript">

function rdBtn_onClick()
{
document.getElementById("btn_delete_list").enable=true;
document.getElementById("btn_showRes").enable=true;

}
    </script>

can the problem be from the place of script tag? I put it under content tag.

2 Answers 2

1

Change your JavaScript to this

<script language="javascript" type="text/javascript">  
    function rdBtn_onClick() {

    document.getElementById("<%= btn_delete_list.ClientID %>").disabled = false;
    document.getElementById("<%= btn_showRes.ClientID %>").disabled = false;

    }
</script>

I'm guessing that the problem is to do with INamingContainer changing the ids of controls in the rendered HTML sent to the client.

Where are the buttons in your markup? What does the HTML look like when you View Source?

Sign up to request clarification or add additional context in comments.

2 Comments

thanks, this way it doesn't say null, but doesn't get the buttons eather
Thank you very much, it finally worked, by combining these two answers. Thanks again
1

can the problem be from the place of script tag? I put it under content tag.

No.

Where are the buttons? View the generated html source. Are the buttons there with the id you are looking for?

Also, it should be element.disabled = false, not element.enable = true

1 Comment

Thank you very much, it finally worked, by combining these two answers. Thanks again

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.