一个APS.NET的问题

来源:百度知道 编辑:UC知道 时间:2024/05/22 18:47:07
我要做一个 有两个按钮 按BtnA 出来一个Panel 按BtnB 出来另一个Panel 这两个Panel都是隐藏的 按相应的Btn就出来 做成客户端的

在page_load里边写如下代码
this.BtnA.Attributes.Add("onclick", "document.form1.UpdatePanel2.PanelA.Visible=true;");

运行,出现javascript错误,说document.form1.UpdatePanel2.PanelA.Visible为空或不是对象。

为什么? 怎么解决?
Can you speak in Chinese?

The point of using ASP.Net, is that you don't bother embed VB/C# code in the HTML Code. Instead, you use CodeBehind to put all the codes in, and put all the design stuff in the webpage. Imagine the situation that you may end up with, say you and a web designer working together on a project. You, as a coder, knows nothing about web design, and the web designer knows nothing about coding VB/C# as well. In the traditional embedded web programming language (PHP,ASP, etc.), the above senario is very very hard to overcome. It becomes extremely difficult for both of you to work together. You may end up with telling him to finish the design first, then you can do you code, which is far more inefficient, than seperating the web design job and code behind up. I strongly recommend you to read more asp.net books, thoroughly. Then you will see the way to substitute <%=... %>