Click here to Skip to main content
16,020,811 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Friends,
I m trying to Add server control from javascript.

it add on the page as well as it shows on page.

But i can't access this control on server side.

Code:

C#
function Append_control() {
            //debugger;
            var panel1 = document.getElementById("<%= pnlRepeatStep1.ClientID %>").innerHTML;
            var panel = document.getElementById("<%= Panel1.ClientID %>").innerHTML;
            //panel = panel.replace(/ConterPlaceHolder1_/g, "ConterPlaceHolder1_D" + count);
            var new_pnl = document.createElement("DIV");
            new_pnl.id = "Panel2";
            new_pnl.innerHTML = panel;

            document.getElementById("<%= pnlRepeatStep1.ClientID %>").appendChild(new_pnl);
            return false;


}

Can any body has this solution.
or any alternate solution for the same.

Thanks in Advance.
Posted
Comments
soni uma 11-Mar-11 4:50am    
You can not get control at server side added using client side.
Sunasara Imdadhusen 11-Mar-11 6:11am    
Right Uma! you are not able to get control from server side if you could added using Javascript.

1 solution

As such you cannot create server controls in Javascript. They would be client controls only and thus you won't be able to access them on server side.
But, you can take approach of XMLHttpRequest from Javascript to achieve the same.

Have a look at these blogs and discussions:
Creating Custom ASP.NET Server Controls with Embedded JavaScript[^]
Similar discussion[^]
 
Share this answer
 

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