I'm creating some textboxes and labels dynamically and am trying to hide/show them via JQuery but can't get the JQuery working. What am I doing wrong?
Here's the code behind:
TableCell td4 = new TableCell();
Label l2 = new Label();
l2.ID = "lbSell" + dp.dSellAutoID.ToString();
l2.Text = Math.Round(Convert.ToDecimal(dp.dSellPrice), 2).ToString();
l2.Visible = false;
td4.Controls.Add(l2);
TextBox tb1 = new TextBox();
tb1.ID = "tbSell" + dp.dSellAutoID.ToString();
tb1.Width = 50;
tb1.Text = Math.Round(Convert.ToDecimal(dp.dSellPrice), 2).ToString();
td4.Controls.Add(tb1);
tr.Cells.Add(td4);
And here's the JS:
function editRow(rowID) {
//alert(rowID);
$('#' + 'lbSell' + rowID).show();
$('#' + 'tbSell' + rowID).hide();
}
Are you using master pages? In that case, the ID changes while the page is being rendered. To prevent it, you can add ClientIDMode="Static"
to the page directive
<%@ Page Title="" Language="C#" ClientIDMode="Static" MasterPageFile="~/epinet.master" %>
Please see: https://stackoverflow.com/a/5494142/5746368
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.