更新时间:2022-06-20 08:08:08
你应该注册的页面明智的
]]>
]]>
明智的身体部分
Your Page you Should Register Like wise
]]>
]]>
Body Section like wise
< asp:button id =btn1runat =servertext =点击xmlns:asp =#unknown>
codeFile有:
<asp:button id="btn1" runat="server" text="Click" xmlns:asp="#unknown">
codeFile have :
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack)
userNews.SrcNews = "Chrysanthemum.jpg";
}
usercontrol修改属性
usercontrol modify the Property
public string SrcNews
{
get { return imgNews.Attributes["src"];}
set { imgNews.Attributes["src"] = value;}
}
i希望此代码能够正常工作
i hope this code will work
在您的源代码中,您应该更改SrcNews
属性如下:
In your source code you should change yourSrcNews
property like bellow:
public string SrcNews
{
get { return imgNews.Attributes["src"];}
set { imgNews.Attributes["src"] = value;}
}
您好
i有一个澄清。在访问您可以创建的属性之前该用户控件的实例并尝试访问该属性SrcNews。
Ex:
您已注册一个名为Usercontrol1的用户控件.ascx。
你明智地编写代码
Usercontrol1 objUserControl = Page.FindControl(Usercontrol1.ascx);
objUserControl.SrcNews =;
现在您可以访问此属性。
Hi
i have one clarification.before accessing the property you could create the instance for that user control and try to access that property "SrcNews".
Ex:
you have registered one usercontrol called "Usercontrol1.ascx".
you write the code like wise
Usercontrol1 objUserControl=Page.FindControl("Usercontrol1.ascx");
objUserControl.SrcNews="";
now you may access this property.