从代码后面创建单选按钮,但有一个onclick

create radio button from code behind but with an onclick?

本文关键字:有一个 onclick 单选按钮 创建 代码      更新时间:2023-09-26

我有一个表在前端…

<table>
<tr>
<td style="padding-right:8px">
<input id="mmapMS" type="radio" name="Layers" value="mmapMS" onclick="addLayer()" style="display:none"/>
<label class="Layer-cc mMS" for="mMS" data-tip="mMS"></label>
</td>
</tr>
</table>

需要更改单选按钮从后端运行…到目前为止,一切都很好(下面),但我不知道如何调用一个js函数,当我点击单选按钮??

                TableRow row = new TableRow();
                TableCell cell = new TableCell();
                HtmlInputRadioButton btn = new HtmlInputRadioButton();
                btn.ID = mapGenieImage;
                btn.Value = mapGenieImage;
                btn.Visible = false;
                cell.Controls.Add(btn);
                Label lb = new Label();   
                lb.CssClass = "Layer-cc " + mapImage;
                cell.Controls.Add(lb);
                row.Cells.Add(cell);
                table.Rows.Add(row);

HtmlInputRadioButton btn = new HtmlInputRadioButton();
btn.ID = mapGenieImage;
btn.Value = mapGenieImage;
btn.Visible = false;
btn.attributes.add("onclick","addLayer()")  '<-- Add me.
cell.Controls.Add(btn);

创建控件时,添加onClick属性,该属性调用addLayer()脚本。

相关文章: