服务器控件从Javascript添加 [英] Server control add from Javascript

查看:81
本文介绍了服务器控件从Javascript添加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,
我正在尝试从JavaScript添加服务器控件.

它既可以在页面上添加,也可以在页面上显示.

但是我无法在服务器端访问此控件.

代码:

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:

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.

推荐答案

因此,您无法在Javascript中创建服务器控件.它们仅是客户端控件,因此您将无法在服务器端访问它们.
但是,您可以采用Javascript中的XMLHttpRequest的方法来实现相同的效果.

看看这些博客和讨论:
创建自定义ASP.带有嵌入式JavaScript的NET服务器控件 [类似的讨论 [ ^ ]
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[^]


这篇关于服务器控件从Javascript添加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆