Sign up ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

This may not be possible but thought i would ask. Creating a Sharepoint webpart. In the ascx file i have a style tag. Is there any way that i could do the following:

    <style type="text/css">
       border: 1px solid Black;
       height:<%# webPartHeight %>;

where the value for height is set via a data binding expression (code behind property). I tried it and when i inspected the style the height had no value set. Any help appreciated either way :)

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Just call DataBind() in, say, Page_Load and it will bind your properties to the page and you can use the exact syntax you have there.

protected string webPartHeight { get; set; }
protected void Page_Load(Object sender, EventArgs e)
    webPartHeight = "400px";
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.