Prasad Bolla's SharePoint Blog

Click Here to go through the Interesting posts within my Blog.

Click Here to go through the new posts in my blog.

Thursday, May 24, 2012

init.js bug in SharePoint 2007 site.


To fix this bug Run Microsoft Office Diagnostic Tool in Microsoft Office.

Note:-
This bug will cause in Individual System.



Tuesday, May 08, 2012

ID's going on changing in Custom List Forms.


I have created a custom list Edit form. If you use the form along with WebPart Zone the ID's will be changed after some check in & check out's. For this you have to create the custom list form in td directly instead of using it in WebPart Zone. Now even if the Control ID Changes you can again remove the automatic generate ID and save the form. Now it will be get reflected as you are not using the WebPart Zone.

Monday, April 23, 2012

How to pass Current Logged User value into SharePoint Created By Column while insertion into SharePoint List.


SPSecurity.RunWithElevatedPrivileges(delegate()
            {
            SPWeb currentWeb = SPContext.Current.Web;   
            SPList lst = currentWeb.Lists["Sample"];
                SPListItemCollection myColl = lst.Items;
                SPListItem item = myColl.Add();
                item["Title"] = txtTitle.Text;   
                SPFieldUserValue value = new SPFieldUserValue(currentWeb, currentWeb.CurrentUser.ID, currentWeb.CurrentUser.LoginName);
                item["Author"] = value.LookupId;
                item.Update();

            });

Friday, April 13, 2012

How to check if the Logged user is in Multiple Groups....!

try
            {
                writer.Write("<Table width='100%'>");
                writer.Write("<Tr>");
                writer.Write("<Td Align='Center'>");
                writer.Write("<Strong>");
                writer.Write("How to check if the current logged user is in Multiple Groups...!");
                writer.Write("</Strong>");
                writer.Write("<Td>");
                writer.Write("</Tr>");
                bool strCurrentUser = false;
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    SPWeb currentWeb = SPContext.Current.Web;
                    SPGroupCollection grp = currentWeb.Groups;
                    foreach (SPGroup group in grp)
                    {
                        if (group.ID == 5)
                        {
                            strCurrentUser = true;
                        }
                    }
                    if (strCurrentUser == false)
                    {
                        writer.Write("<Tr>");
                        writer.Write("<Td>");
                        writer.Write("<Strong>");
                        writer.Write("Current user is not an Administrator...!");
                        writer.Write("</Strong>");
                        writer.Write("<Td>");
                        writer.Write("</Tr>");
                    }
                    else
                    {
                        writer.Write("<Tr>");
                        writer.Write("<Td>");
                        writer.Write("<Strong>");
                        writer.Write("Current User is an Administrator");
                        writer.Write("</Strong>");
                        writer.Write("<Td>");
                        writer.Write("</Tr>");
                    }

                });
                writer.Write("</Table>");

            }
            catch (Exception ex)
            {

                writer.Write(ex.ToString());
            }