// Set the properties newStylesheet.StylesheetDisplayName = "My new stylesheet"; newStylesheet.StylesheetName = "MyNewStylesheet"; newStylesheet.StylesheetText = "Some CSS code";
// Save the css stylesheet CssStylesheetInfoProvider.SetCssStylesheetInfo(newStylesheet); }
The following example gets and updates a stylesheet.
privatebool GetAndUpdateCssStylesheet() { // Get the css stylesheet CssStylesheetInfo updateStylesheet = CssStylesheetInfoProvider.GetCssStylesheetInfo("MyNewStylesheet"); if (updateStylesheet != null) { // Update the properties updateStylesheet.StylesheetDisplayName = updateStylesheet.StylesheetDisplayName.ToLower();
// Save the changes CssStylesheetInfoProvider.SetCssStylesheetInfo(updateStylesheet);
returntrue; }
returnfalse; }
The following example gets and bulk updates stylesheets.
privatebool GetAndBulkUpdateCssStylesheets() { // Prepare the parameters string where = "StylesheetName LIKE N'MyNewStylesheet%'";
// Get the data DataSet stylesheets = CssStylesheetInfoProvider.GetCssStylesheets(where, null); if (!DataHelper.DataSourceIsEmpty(stylesheets)) { // Loop through the individual items foreach (DataRow stylesheetDr in stylesheets.Tables[0].Rows) { // Create object from DataRow CssStylesheetInfo modifyStylesheet = newCssStylesheetInfo(stylesheetDr);
// Update the properties modifyStylesheet.StylesheetDisplayName = modifyStylesheet.StylesheetDisplayName.ToUpper();
// Save the changes CssStylesheetInfoProvider.SetCssStylesheetInfo(modifyStylesheet); }
returntrue; }
returnfalse; }
The following example deletes a stylesheet.
privatebool DeleteCssStylesheet() { // Get the css stylesheet CssStylesheetInfo deleteStylesheet = CssStylesheetInfoProvider.GetCssStylesheetInfo("MyNewStylesheet");
// Delete the css stylesheet CssStylesheetInfoProvider.DeleteCssStylesheetInfo(deleteStylesheet);