简体   繁体   English

从后面的代码创建单选按钮,但带有onclick?

[英]create radio button from code behind but with an onclick?

I had a table in front end... 我在前端有一张桌子...

<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>

Need to change the radio button to run from the back end...all good so far (below) but I cant find out how to call a js function when I click the radio button??...onclick="addLayer()" any ideas...thanks 需要更改单选按钮以从后端运行...到目前为止一切都很好(如下),但是当我单击单选按钮时我无法找到如何调用js函数的方法?... onclick =“ addLayer() “任何想法...谢谢

                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);

When creating your control, add an attribute of onClick which calls your addLayer() script. 创建控件时,添加onClick属性,该属性调用addLayer()脚本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM