Take the 2-minute tour ×
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">
    outerDiv
    {        
       border: 1px solid Black;
       height:<%# webPartHeight %>;
       width:300px;
    }
</style>

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
add comment

1 Answer

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";
    DataBind();
}
share|improve this answer
add comment

Your Answer

 
discard

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.