How to emit string into user control from code behind?
I have a main aspx page in which there is a list of items. Each item is shown using the user control. Now i am trying to emit string in user control is page receives specific parameter through user control as below.
//ASCX code
..
<span><%=custString %></span>
..
// .CS code
protected string custString = string.Empty;
..
protected void Page_Load(object sender, EventArgs e){
if(Request.params["chages_done"]){
custString = "Values updated ";
}
}
So while debugging i can see the value of 开发者_开发知识库the string getting updated but its not getting reflected on the ascx control when its added to page. Any idea how it can be achived ? or what can be wrong ? I have also tried to create the server side control in user control and setting its value from code behind but it too was not working.
Add a public string property to your control, and a Literal control to the .ascx markup. When the property is set, set the value of the Literal control as well. Should do the trick.
精彩评论