asp.netscrollbarinnerhtmlhtmlgenericcontrol

How to make scroll bars work in HtmlGenericControl("Div")


    HtmlGenericControl SpecsDiv = new HtmlGenericControl("Div");
    SpecsDiv.InnerHtml = "<b>Specifications are not defined.</b>";
SpecsDiv.Style.Add("left", "0");
SpecsDiv.Style.Add("width", "100");
    SpecsDiv.Style.Add("height", "200");
    SpecsDiv.Style.Add("overflow", "scroll");

Above is the definition and within the .cs the value of SpecsDiv gets assigned to the path of an image (not shown in the above code example). Sometimes these images are bigger in width/height than what is specified above.

Currently the scroll bar appears (but disabled) and also the image (which is bound to the above SpecsDiv) spills over beyond the scroll bar because the images are bigger.

Should I wrap SpecsDiv within a table? or something else? Still checking the options.


Solution

  • if your image is spilling out, it may be because you are styling it incorrectly. Are you making it float? or display:absolute? without seeing the style for the image it will be hard to make a recommendation.

    You must make sure the image is part of the normal flow, and you probably want overflow: auto so that scroll bars are not present unless it overflows.