im coding a system whereby pieces of content (widgets) can be added to the page by editors and laid out according to their widths... this is simply 3,6,9 or 12 cols for a 12 col max width row....
code is straightforward but just having a few issues....
firstly im trying to cast an ipublishedcontent property to an interger to increment my widthcol counter but getting an error "input string was not in the corect format..
int widgetWidth = Convert.ToInt32(widget.GetPropertyValue("widgetWidth"));
More of an issue is when a module exceeds the 12 col width i want to start a new line ( a div to clear) but not sure how i would do this....
i presume i could either create a property on my widget doctype then set this on the model prior to being passed to the relevant partial view... or is there a way to pass some html string (ie the <div class="clear"></div> as an overlaod in the partial view call ?
my code is:
foreach (IPublishedContent widget in widgets) { // get the widget width int widgetWidth = 3; //Convert.ToInt32(widget.GetPropertyValue("widgetWidth")); rowColumnWidth = rowColumnWidth + widgetWidth;
if (rowColumnWidth <= maxRowColumnWidth) { // get the widget name var widgetname = widget.GetPropertyValue("widgetPicker").ToString().Replace(" ", ""); // add widget to get the correct partial view var partialviewName = widgetname + "Widget"; // call the partial view with the model object Html.RenderPartial(partialviewName, widget); } else { // reset width rowColumnWidth = widgetWidth; // output a new line to start a new row ????????????????????????????? // get the widget name var widgetname = widget.GetPropertyValue("widgetPicker").ToString().Replace(" ", ""); // add widget to get the correct partial view var partialviewName = widgetname + "Widget"; // call the partial view with the model object Html.RenderPartial(partialviewName, widget); }
dynamic modules
im coding a system whereby pieces of content (widgets) can be added to the page by editors and laid out according to their widths... this is simply 3,6,9 or 12 cols for a 12 col max width row....
code is straightforward but just having a few issues....
firstly im trying to cast an ipublishedcontent property to an interger to increment my widthcol counter but getting an error "input string was not in the corect format..
int widgetWidth = Convert.ToInt32(widget.GetPropertyValue("widgetWidth"));
More of an issue is when a module exceeds the 12 col width i want to start a new line ( a div to clear) but not sure how i would do this....
i presume i could either create a property on my widget doctype then set this on the model prior to being passed to the relevant partial view... or is there a way to pass some html string (ie the <div class="clear"></div> as an overlaod in the partial view call ?
my code is:
foreach (IPublishedContent widget in widgets)
{
// get the widget width
int widgetWidth = 3; //Convert.ToInt32(widget.GetPropertyValue("widgetWidth"));
rowColumnWidth = rowColumnWidth + widgetWidth;
if (rowColumnWidth <= maxRowColumnWidth)
{
// get the widget name
var widgetname = widget.GetPropertyValue("widgetPicker").ToString().Replace(" ", "");
// add widget to get the correct partial view
var partialviewName = widgetname + "Widget";
// call the partial view with the model object
Html.RenderPartial(partialviewName, widget);
}
else
{
// reset width
rowColumnWidth = widgetWidth;
// output a new line to start a new row
?????????????????????????????
// get the widget name
var widgetname = widget.GetPropertyValue("widgetPicker").ToString().Replace(" ", "");
// add widget to get the correct partial view
var partialviewName = widgetname + "Widget";
// call the partial view with the model object
Html.RenderPartial(partialviewName, widget);
}
}
is working on a reply...