使用aspx页面中的UserControl按钮 [英] use UserControl Button in the aspx page

查看:86
本文介绍了使用aspx页面中的UserControl按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UserControl UC1.ascx,正在网页NEW.aspx,UPDATE.aspx,DELETE.aspx中使用.用户控件中有3个按钮NEW,UPDATE,DELETE,所有这些按钮在用户控件中都是不可见的.

I have a UserControl UC1.ascx which I am using in a web page NEW.aspx,UPDATE.aspx,DELETE.aspx. There are 3 buttons in the user control NEW,UPDATE,DELETE and all these buttons are invisible in the user control.

我想在打开页面NEW.aspx时使NEW buttone可见,而其他2个按钮都相同...

I want to make NEW buttone visible when I open page NEW.aspx and same for the other 2...

我尝试了followinf,该错误给出为"对象引用未设置为对象的实例"

I tried followinf which gives an error as " Object reference not set to an instance of an object"

按钮

 

btn = 按钮 btn =(

按钮 ) .Page.FindControl( " User1" );;     //error            

//User1是用户控件的ID,并且 btnNewUser是用户控件中按钮的ID

如果

 

(btn!= )

{

(btn != null)

{

btn.Visible = ;}

推荐答案

首先,您应该在http://forums.asp.net/上发布此问题,其次,当您进行此操作时会有所帮助在页面的生命周期中执行此代码时发布.如果您发布整个代码,则也很有帮助,在此示例中,该按钮将永远不会添加到页面的控件中...
first you should post this question at http://forums.asp.net/, second it would be helpfull when you post when this code is executed in the lifecycle of the page. Also helpful would be if you post the whole code, in this sample, the button will never be added to a control colleciton of the page...


这篇关于使用aspx页面中的UserControl按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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