views:

30

answers:

2

Hi, 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.

+1  A: 

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

Chetan Sastry
Thank you very much, it finally worked, by combining these two answers. Thanks again
Ehsan
+1  A: 

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?

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