UserControl doesn't include properties such as "Height" or "Width";So plz adjust the inner control。Sample if I put a button inside a usercontrol,you should adjust the button's Height and Width——
namespace CSharp
{
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//Dynamically adding controls……
Control c= LoadControl("MyUserControl.ascx");
(c.FindControl("Button1") as Button).Height = new Unit(300.5);
(c.FindControl("Button1") as Button).Width = new Unit(300.5);
form1.Controls.Add(c);
}
}
}
}
Ravi0207
Member
16 Points
9 Posts
ASCX control height and width
Feb 09, 2012 12:43 PM|LINK
Hi
How to set ascx control height and width, when i place my control in web page its width gets shirnked. i am placing ascx control dynamically
Any suggestion would be appreciated.
Regards
Ravi
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: ASCX control height and width
Feb 11, 2012 12:30 AM|LINK
Hello:)
UserControl doesn't include properties such as "Height" or "Width";So plz adjust the inner control。Sample if I put a button inside a usercontrol,you should adjust the button's Height and Width——
namespace CSharp { public partial class Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //Dynamically adding controls…… Control c= LoadControl("MyUserControl.ascx"); (c.FindControl("Button1") as Button).Height = new Unit(300.5); (c.FindControl("Button1") as Button).Width = new Unit(300.5); form1.Controls.Add(c); } } } }Ravi0207
Member
16 Points
9 Posts
Re: ASCX control height and width
Feb 15, 2012 06:47 AM|LINK
Thanks much, i will try this and let you know the feedback.