把一个 Label1 放到 UpdatePanel 里面,label = (Label)ctrl.FindControl("Label1");调试提示:label 为 null,运行出错:未将对象引用设置到对象的实例。但是只要把 Label1 拖到 UpdatePanel 外面,是没问题的!大家帮帮忙吧。
解决方案 »
- XML数据读取
- 不用循环,怎样将DataTable中的某一列转换成string[]?
- 谁能介绍一个有朋友圈或者说是部落功能的开源项目,或者那个公司有这种产品?
- 2003与2005在数据获取方面的不同?
- ASP.NET调试出现错误,不知何故?
- 读写文件 中文变成乱码,谁能给出解决方案
- asp.net mvc3 下开发,下面是我的前台代码,想请教大神,怎么做这个页面的后台,因为下列代码是copy别人php开发的,所以不清楚怎么弄,谢谢
- 这个如何实现
- 那位大侠有在datagrid中有一个按钮,点击这个按钮,就弹出一个窗口,在这个窗口中
- 请问:在CS中怎么得到导致页面刷新的控件的ID
- 请教关于table中的内容导出到word里的问题
- 用户自定义控件,有属性gid,在page_load中取不到属性值
Sub ttk(sender as object,e as system.eventargs)
Dim lb1 as label
lb=page.findcontrol("label1")
lb.text="你好,这是updatepanel里的label"
Eend sub
</script><form runat="server">
<asp:Updatepanel id="update1" ChildrenAsTriggers="true" runat="server" UpdateMode="Always">
<contenttemplate>
<asp:label runat="server" ID="label1"/>
<cc1:popupwin id="ppw" style="Z-INDEX: 105; right: 0px; POSITION: absolute; TOP: 128px" runat="server" width="230px" height="150px" windowsize="300, 200" windowscroll="False" dockmode="BottomLeft" colorstyle="Blue" gradientdark="210, 200, 220" textcolor="0, 0, 3" shadow="125, 90, 160" lightshadow="185, 170, 200" darkshadow="128, 0, 102" visible="False" showlink="True" OffsetX="0">
</cc1:popupwin>
<asp:Timer id="tm1" runat="server" enabled="true" interval="10000" ontick="ttk"></asp:Timer>
</contenttemplate>
</asp:Updatepanel>
</form>
Sub ttk(sender as object,e as system.eventargs)
Dim lb1 as label
lb=page.findcontrol("label1")
lb.text="你好,这是updatepanel里的label"
Eend subtoSub ttk(sender as object,e as system.eventargs)
Dim lb1 as label
lb=page.findcontrol("label1")
lb.text=now()
Eend sub
在body中<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
控件才能使用
下面的你参考!参考
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="确定" />
<asp:Button ID="Button2" runat="server" Text="取消" OnClick="Button2_Click" />
<asp:Label runat="server" ID="InputTimeLabel"><%=DateTime.Now %></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
刚才忘记放<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
Sub ttk(sender as object,e as system.eventargs)
Dim lb1 as label
lb=page.findcontrol("label1")
lb.text=now()
Eend sub
</script><form runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:Updatepanel id="update1" ChildrenAsTriggers="true" runat="server" UpdateMode="Always">
<contenttemplate>
<asp:label runat="server" ID="label1"/>
<asp:Timer id="tm1" runat="server" enabled="true" interval="10000" ontick="ttk"></asp:Timer>
</contenttemplate>
</asp:Updatepanel>
</form>
条件:1 个 aspx 页面,1 个ascx 用户控件
三种情况:
1、把 ScriptManager Updatepanel 同时放在 aspx 页面,ascx 拖进 Updatepanel 里,运行没问题。FindControl 成功找到。2、把 ScriptManager Updatepanel 同时放在 ascx 页面,运行出错,不能把控件 FindControl 出来3、把 ScriptManager 放在 aspx 页面 Updatepanel 放在 ascx 页面,运行出错,错误同 2 难道真的只能用第一种方法?要把整个 ascx 放进去?