Click here to Skip to main content
15,905,420 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi ,
Im creating html label using javascript. The labels are creating and showing in browser window. But i cant find the dynamically created label name using another javascript.

Note: In view source the dynamic created labels are not showing.

Here is the function that im using for creating rows(labels)

JavaScript
function OnButtonClick_txt_rows(sender, eventArgs) 
{
    var runat = ' runat="server";"';
    var DDL_Header_Align = $find("DDL_Header_Align");
    if (eventArgs.get_buttonType() == 2) 
    {
        var txt_rows = $find("txt_rows");
        var tbody = document.getElementById("t1").getElementsByTagName("tbody")[0];
        var row = document.createElement("TR");
        for (i = 0; i <= t1.rows[0].cells.length - 1; i++) 
        {
            var cell1 = document.createElement("TD");
            var Literal1 = document.getElementById("Literal1")
            cell1.innerHTML = '<tr><td><table ><tr><td colspan=10><div id=div_lbl_print_header' + i + 'style=text-align:' + DDL_Header_Align.get_value() + '><Label id=lbl_print_header' + i + '>' + document.getElementById("txt_Barcode_header").value + '<Label></div></td></tr>';
            cell1.innerHTML += '<tr><td colspan=10><div id=div_lbl_print_value_top' + i + '  ><Label runat ID=lbl_print_value_top' + i + ' class=' + document.getElementById("lbl_print_value_top").className + '></Label></div></td></tr>'
            cell1.innerHTML += '<tr><td colspan=10><div id=div_lbl_print_barcode' + i + '><Label runat ID=lbl_print_barcode' + i + '>' + document.getElementById("txt_Barcode_value").value + '</Label></div></td></tr>'
            cell1.innerHTML += '<tr><td colspan=10><div id=div_lbl_print_value' + i + '><font face="Free 3 of 9"><Label runat ID=lbl_print_value' + i + '>' + document.getElementById("txt_Barcode_value").value + '</Label></font></div></td></tr>'
            cell1.innerHTML += '<tr><td colspan=10><div id=div_lbl_print_Footer' + i + '><Label runat ID=lbl_print_Footer' + i + '>' + document.getElementById("txt_Barcode_Footer").value + '</Label></div></td></tr></table></td></tr>'
            Literal1.innerHTML = cell1.innerHTML
            row.appendChild(Literal1);
        }
        tbody.appendChild(row);
    }
    else 
    {
        var table = document.getElementById("t1");
        var rowCount = table.rows.length;
        if (rowCount != 1)
        table.deleteRow(rowCount - 1);
    }
}
Posted
Updated 23-Dec-11 2:12am
v2

1 solution

Did you mean to do this:

<Label runat ID=...

shoudln't it be runat='server'?

Furthermore, should it be ID = 'my_id' (you're missing the quoites around the values)?
 
Share this answer
 
Comments
RaisKazi 23-Dec-11 8:30am    
OP's comments[Moved here from Solution-2] -

Hi, Mr.John Simmons,

I too try that. Its also not coming. But the label text is displaying in browser but i couldn't find in view-source.

<Label runat ID=.
runat I declared it as var runat = ' runat="server";"';

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900