.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

How do I change the default HTML code for a collection of lists and views

Posted By:      Posted Date: August 26, 2010    Points: 0   Category :SharePoint

I have modified the html display code of some lists and content query web parts in SharePoint designer.  This works well when modifying a few lists, but I have many lists and different views with these many lists.

Is there a way to modify the template code for a site so that all my lists, views and CQWPs display identically with my modified code?  Managing these individually is not practical.

View Complete Post

More Related Resource Links

dynamically change html code when user is authenticated


So I have a fairly simple web site which allows an Administrator to edit some data in a database which is displayed on some web pages.

The main navigation on the site is shown in the code snippet below. The Admin link goes to a Login.aspx which allows the Administrator to log in - once authenticated they get sent to the data edit page.

So my question is, how could I dynamically add a link to the data edit page in the <ul> list below once the user is authenticated ?

This would allow the authenticated user to see links to the secure pages in the main navigation bar.

<%--Top Navigation Menu --%>
<div id="topMenu">
<li><a href="default.aspx">Home</a></li>
<li><a href="introduction.aspx">Introduction</a></li>
<li><a href="curriculum.aspx">Curriculum</a></li>
<li><a href="times.aspx">Times & Fees</a></li>
<li><a href="staff.aspx">Staff</a></li>
<li><a href="login.aspx">Admin</a></li>
</div><%--End of topMenu Container--%>
<div id="clear"></div><%--Floats items cleared End of Master Page--%>

MVC2: Change the default generated HTML when creating a strongly typed view


Is there any way to change the HTML that is generated by default when you create a strongly typed view in MVC2?

I currently get a structure like this:

            <div class="editor-label">
                <%: Html.LabelFor(model => model.category_id) %>
            <div class="editor-field">
                <%: Html.TextBoxFor(model => model.category_id) %>
                <%: Html.ValidationMessageFor(model => model.category_id) %>

I want to change it to a structure like this:

                <div><%: Html.ValidationMessageFor(model => model.user_login) %></div>
                <div><%: Html.LabelFor(model => model.user_login) %></div>
                <div><%: Html.TextBoxFor(model => model.user_login) %></div>

How to change the default page base class?


I've tried setting the <pages pageBaseType="DynamicWebPage" /> value in web.config, but when I response.write out the page type, I'm still getting Microsoft.WebPages.WebPage.

I'm simply trying to sub-class WebPage and add some additional functionality such as a dynamic PageData dictionary similar to Phil Haack's dynamic ViewData dictionary.



change the code vb to c#


Namaste to everyone.

I need help in converting VB Code to C# Code. The code is:-

            dim thisPage as System.Web.UI.Page
            dim nameTextBox as TextBox
    thisPage = CType(Context.Handler, System.Web.UI.Page)
    nameTextBox =  CType(thisPage.FindControl("txtName"), System.Web.UI.Control)

    lblName.Text = "Your name is '" & nameTextBox.Text & "'."


The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)


Hey guys

I came across this bug using while trying to implement a sitemap

Line 147:						Panel panel = new Panel();
Line 148:						panel.Controls.Add(_viewState);
Line 149:						Page.Form.Controls.Add(panel);
Line 150:						string script = "document.getElementById('" + _viewState.ClientID + "').value = GetViewState__AspNetTreeView('" + Extender.MakeChildId("UL") + "');";
Line 151:						Page.ClientScript.RegisterOnSubmitStatement(typeof(TreeViewAdapter), _viewState.ClientID, script);

[HttpException (0x80004005): The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).]
   System.Web.UI.ControlCollection.Add(Control child) +8696951
   CSSFriendly.TreeViewAdapter.SaveAdapterViewState() in E:\wwwroot\ThirdParty\CSSFriendly\CSSFriendly_24242\CSSFriendly\TreeViewAdapter.cs:149
   System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode) +8901848
   System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode) +148
   System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode) +148
   System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode) +148

how to change default menu tab in master pages?



i have 5 tabs in my master page application. how can i make 2nd tab as default?

any ideas?


Change grid view from table to other HTML layout



You'll have to excuse my ignorance, I'm coming at this from a front-end perspective, and don't really know how to deal with data views in ASP.NET.

Basically, I'm trying to change the layout of some repeated data from a straight table, to something more design-heavy.  It's the same data, just re-organised slightly.  The current ASP.NET code looks like this:

                    <asp:GridView ID="GVMoments" runat="server" AllowPaging="True" AllowSorting="True"
                        AutoGenerateColumns="False" PageSize="20" RowHeaderColumn="FirstName"
                        SkinID="GroupSkin" DataKeyNames="moment_id" 
                        <PagerSettings Mode="NumericFirstLast" PageButtonCount="20" Position="TopAndBottom" />
                        <RowStyle />
                                <asp:BoundField DataField="moment_id" HeaderText="moment_id" ReadOnly="True" SortExpression="moment_id"
                                    Visible="False" In

Change the Workflow Status through code


HI Folks,

I have a scenario where i need to develop a 6 stage approval workflow(sequential) using WWF and depoly it to sharepoint. Everythigns fine till here.

Now we look ahead to change the Status field on the documents library which actually has the Workflow Name as the column name and its value being In Progress, depending on the stage of approval. Like(Approved 1, Approved 2, Approved 3.)

And if rejected the status should be rejected than Completed. Any idea how can we update this column of the List item.

I have tried item[workflowProperties.Workflow.ParentAssociation.Name]="Approved 1";

But this throws an error saying input string is not in a correct format.

Any information would be of great help :)


Sreeharsha Alagani

Is it possible to change the title bar background and the font style on default template?



Is there any way to change the default top link /title bar picture and the fonts of the title without breaking anything in the layout/structure?

I have changed the theme to Obsedian and I would also like to change the picture of the title bar of this theme and also the font/style of the title, top link bar, menus..etc. Is there a way to do this?

Please note: I am using WSS 3.0 and I am not the Administrator of the sharepoint. I am only the site admin of some sites on this sharepoint. I can do some basic customization using SPD.

Basically, what I am trying to do is that I want to set up a sharepoint site, however I want to make it NOT look like a sharepoint site.Well I know this is possible, but for my case it might be just partially possible due to the limitation that I am not the Site collection admin and hence I do not have direct access to the server itself.

What I want is to hide most of the sharepoint links/menus/bars, etc and use my own buttons/hyperlinks etc .. for user to navigate on the sites.

Thanks in advance for your help/advices.



VB.NET - store HTML code in SQL Server


Hey guys/gals!!

Quick question - I want to allow someone to enter HTML markup in a control, and save the input exactly as entered. 

I want people to put a minimum of 50 words, to maximum of 500, and be able to save the formatting of their text in SQL 2005 server database. 

Also, I understand this is two questions, but how do I save metadata of an image file in the sql database? I mean, I get the gist of it, but how do I do it? 

Thanks everyone!

How to change this code to allow more file uploads

I have a page currently setup to upload 1 image at a time, it uploaded the image, then creates a thumbnail for that image in the same directory. Client needs / wants to be able to upload a few more images at the same time. So i would like to see if i can use the existing code that works, but setup to upload a few more images and process them all to create the thumbnails. I currently have a page that allows them to upload 5 images at a time and that works fine, but its just simple uploading the images, nothing else is happening at that moment. Here is the code i am working with: protected void UploadBtn_Click(Object sender, EventArgs e) { String pth = Server.MapPath("~/gallery/homebirth/images/"); String UploadedFile = MyFile.PostedFile.FileName; int ExtractPos = UploadedFile.LastIndexOf("/") + 1; //to retrieve only Filename from the complete path String UploadedFileName = UploadedFile.Substring(ExtractPos, UploadedFile.Length - ExtractPos); // Display information about posted file. Div is invisible by default FileName.InnerHtml = UploadedFileName; MyContentType.InnerHtml = MyFile.PostedFile.ContentType; ContentLength.InnerHtml = MyFile.PostedFile.ContentLength.ToString(); //div is made visible FileDetails.Visible = true; // Save up

Extract text from html source code

i wan to extract Desired Title,Desired Text and Desired link from Webpage source code and paste in richTextBox1. <a href="/site/show/link/0/type/0">Desired Titl e</a> <a title="&lt;b&gt;Text preview&lt;/b&gt; &lt;br/&gt;Some Text" class="pdtip" href="/site/show/link/0/type/0">Text</a><br />Desired text <br /> <label class="url" for="">http://Desiredlink.com </label> Output: Desired Title Desired Title Desired link How can i do this?

DataGrid ValidationRule or IDataErrorInfo validation code called multiple times for each data change

Following my enquiry regarding a problem in Datagrid validation, for which managing exceptions is apparently a problem, I tested the two other methods: using validation rules, or implementing the IDataErrorInfo interface. I ran into other problems there, more insidious this time. This has been done on Windows7 (32-bit), .NET 4.0.30319. 1) IDataErrorInfo When this interface is implemented, the this[string columnName] property is called four times for each modification: two times before the cell enters edit mode (with the old value in the corresponding property) two times when the new value has to be validated (with the new value) It strikes me as not really efficient, is there something wrong with my code? Here's the C# part: using System; using System.Windows; using System.Collections.ObjectModel; using System.ComponentModel; namespace DataGridTest2 { public partial class MainWindow : Window { ObservableCollection<User> users; public MainWindow() { InitializeComponent(); users = new ObservableCollection<User>() { new User { Name = "Teddy", Age = "2" }, new User { Name = "Avi", Age = "19" } }; datagrid.ItemsSource = users; datagrid.Focus(); } } public class User : INotifyPropertyChanged, IDataErrorInfo { string name; public string Name

Html.CheckBoxFor - how can I make checkbox default checked ?

I have:Html.CheckBoxFor(model => model.available) how can I have checkbox default checked ?

How to handle differences in HTML code from different browser versions?

First of all I'm still very new to C# so be gentle :p I'm currently trying to make an application that can login to a certain website and search for some numbers and so on that I can put in an overview, just to save some time. The only thing I found that could do this is the WebBrowser control, and I've managed to make it work, but when I gave the program to a friend it failed. I think it has to do with the difference in browser versions (he uses Internet Explorer 7, I use the latest) and if that's the case I'm pretty clueless how to deal with the problem, since I don't even know what the differences in HTML codes are in each version, and it seems like a lot of work to adjust all the html code to check for accordingly. For example it was even so that & changed to &amp; in my application on my PC and that's only by using one browser so I dunno what happens with other browser versions. I assume that the WebBrowser control always uses Internet Explorer, even if for example Firefox is the standard browser, is this true? But to be sure I asked the friend to put his Internet Explorer as the default browser and still no go. So my question is: is there a relatively easy way to make sure that the program works on practically any PC, without me having to make exceptions for like version 1.6.7 or 1.6.8 (I have no idea what versions there are really)?

Change Default Column Value programatically

On a Document Library Settings Page, there is a new setting in SP2010: "Change Default Column Value". Changing the default value of the Field is different from this value. Does anyone know what this value is and where to set it programatically? Also, what libraries is this setting available on? This code updates the field's default value but not the property mentioned above: SPField field = list.Fields["Column"]; field.DefaultValue = "DefaultValue"; field.Update(); Thanks!
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend