TableRow tr = new TableRow();
TableCell tc = new TableCell();
TextBox tb = new TextBox();
tb.CssClass = "expensesid";
tb.ID = "expensesid" + list.IndexOf(data);
tb.Attributes.Add("onKeyUp", "ShowLength(value," + list.IndexOf(data) + "," + "200);");
tb.Text = data.expensesid;
tc.Controls.Add(tb);
Label cnt = new Label();
cnt.ID = "expensesidCnt" + list.IndexOf(data);
cnt.Text = "入力文字数 " + data.expensesid.Length.ToString() + "/200文字";
tc.Controls.Add(cnt);
tr.Controls.Add(tc);
<script type="text/javascript">
function ShowLength(str,row,maxLength) {
document.getElementById("MainContent_expensesidCnt" + row).innerHTML = "入力文字数 " + str.length + "/" + maxLength + "文字";
}
</script>
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme