Sometimes you want your web page to ‘stay alive’. That is, if a user is filling out a complicated form, that may contain several fields, you do not want the session to time out before they are finished.

It’s not simply a matter of increasing the session timeout to a very large value. If you do that, the sessions would be left active in the server memory for hours—long after the visitors have left the site. Increasing the session timeout IS a solution… but not necessarily a good solution.

The goal is that the session should stay active as long as the web page is open on the client machine …even if there are no post backs to reset the session timer. When the web page is closed, the session should time out normally.

I implemented a solution for this: The client will “ping” the server at intervals of less than the session timeout which will reset the session timer. This is known as the Heartbeat design pattern

For testing purposes, I set the Session Timeout to two minutes in web.config:

<sessionState timeout=”2″></sessionState>

to trace the output of defferent events i used “System.Diagnostic.Debug” class.

To watch the Session State events, I added debugging strings to the global.asax file:

3

Here is what the output looks like without the heartbeat:

1

We need a method at the server for the client to call. We use a WebMethod.

  1. There must be a ScriptManager on the page.
  2. The ScriptManager must have EnablePageMethods set to true.
  3. The WebMethod must be public and static.
  4. The WebMethod must have the EnableSession attribute set to true.

4

5

Here is the output with the heartbeat:

2

It looks like the session is staying alive while the client is idle: Excellent!

I hope someone finds this useful.

if this is helpful, dont forget to leave a comment.

Advertisements

Hi

I just recently got experience of Installing SharePoint 2013 on a standalone machine, set finished very well but got following error in configuration, although central administration was working well but search service application was showing error.

The SDDL string contains an invalid sid or a sid that cannot be translated

at System.Security.AccessControl.RawSecurityDescriptor.BinaryFormFromSddlForm(String sddlForm)
at System.Security.AccessControl.RawSecurityDescriptor..ctor(String sddlForm)
at Microsoft.SharePoint.Win32.SPNetApi32.CreateShareSecurityDescriptor(String[] readNames, String[] changeNames, String[] fullControlNames, String& sddl)
at Microsoft.SharePoint.Win32.SPNetApi32.CreateFileShare(String name, String description, String path)
at Microsoft.SharePoint.Administration.SPServer.CreateFileShare(String name, String description, String path)
at Microsoft.Office.Server.Search.Administration.AnalyticsAdministration.CreateAnalyticsUNCShare(String dirParentLocation, String shareName)
at Microsoft.Office.Server.Search.Administration.AnalyticsAdministration.ProvisionAnalyticsShare(SearchServiceApplication serviceApplication)
at Microsoft.Office.Server.Search.Administration.AnalyticsAdministration.CreateDefaultStoreLocation(SearchServiceApplication serviceApplication)
at Microsoft.Office.Server.Search.Administration.AnalyticsAdministration.ProvisionRawEventStore(SearchServiceApplication serviceApplication)
at Microsoft.Office.Server.Search.Administration.AnalyticsServiceAdministration.Provision()
at Microsoft.Office.Server.Search.Administration.SearchServiceApplication.Provision()
at Microsoft.SharePoint.PostSetupConfiguration.EvalModeProvisionTask.ProvisionServiceApplicationsAndProxies()
at Microsoft.SharePoint.PostSetupConfiguration.EvalModeProvisionTask.Run()
at Microsoft.SharePoint.PostSetupConfiguration.TaskThread.ExecuteTask()

 

 

solution is very easy, navigate to “C:\Program Files\Microsoft Office Servers\15.0\Data\Office Server” you will see a folder starting “Analytics_GUID” , right click the properties, share this folder and give everyone full access.

run configuration wizard again and you will see successful configuration message.

 

Hi reader

We have developed a BCS service which takes data from a SQL server data base using web services, we have created an external list in SharePoint which is connected to the BCS service anad displays data, everything was workig fine but client raised a requirement to have some custom control on the external list form, for example client want to see a dropdown for status of an order, by defalut external list displays data in text boxes, just like below screenshot

After spending almost 2 days, I have got the solution which might save ur 2 days J

Idea is that we will create a custom control that will render a dropdown with all possible values, in the sample application I have included some dummy values. We will configure our BDC modal to use our custom control for displaying field on forms.

This is my class which defines creat child control method pf my custom control which renders a dropdown with fixed entries.

Following class uses above class for rendering

Before moving forward, create a simple list and create a column with your custom field, and perform all CRUD operations to make sure custom control is working well.

My BDC modal class with 2 methods

Read list and read item modal configuration, this is the most important part.

Where “EmailField” is class name of my custom control

So final screen look like

That’s it very simple, let me know if you get confused anywhere.

Hi all

Some days back I was working with update panels and I created a simple application with multiple update panels on my page. Update panels were fetching data from a third part content management system, so sending a request, fetching and displaying the data was not a tricky part of the application but that used to take around 30 to 40 seconds per request.

Initially It was good but later when we customized our application to allow user to add multiple update panels on 1 page, we got stuck with performance issues, when user tried to load a page it used to take 1 or 2 minutes to complete page output.

I searched a lot to find out the way to improve the page performance, I got the idea of lazy loading but that worked well if there was only 1 update panel on the page. After spending lot of time, finally I figured out the lazy loading implementation with unlimited number of update panels, so in ideal situation a web page loads immediately without any third party call and after page load is completed it execute update panel refresh calls from JavaScript and shows a progress bar when update panel is loading the data. So if you have n number of update panels placed on your web page, the update panel placed at first position will start loading and after that 2nd panel load will start then 3rd and so on.

So for the clear understanding of this concept I am creating a user control and that user controls has 1 update panel and some other content controls, I will drop the user control on my page 4 times, so there will be 4 update panels rendered.

Here is the sample script for user control

<asp:UpdatePanel
ID=”upUpdatePanel” runat=”server” UpdateMode=”Conditional” OnPreRender=”upUpdatePanel_PreRender”>

<ContentTemplate><asp:LinkButtonID=”LinkButton1″ runat=”server” Enabled=”false” ForeColor=”Black”Font-Bold=”true” Font-Size=”Large” onclick=”LinkButton1_Click”>LinkButton disabled so far</asp:LinkButton>

<br /><br />

<asp:LabelID=”Label2″ runat=”server” Text=”Label”></asp:Label><asp:HiddenFieldID=”HiddenField1″ runat=”server”/>

<asp:GridView
ID=”GridView1″ runat=”server” PageSize=”3″ AllowPaging=”True” OnPageIndexChanging=”GridView1_PageIndexChanging”>

</asp:GridView>

</ContentTemplate>

</asp:UpdatePanel>

<asp:UpdateProgress
ID=”updProgressTab” runat=”server” AssociatedUpdatePanelID=”upUpdatePanel”>

<ProgressTemplate><divstyle=”position: relative; top: 50%; text-align: center;”>

<asp:ImageID=”imgLoading1″ runat=”server” ImageUrl=”simple.gif” Width=”34px” Height=”30px”/>Refreshing…

</div>

</ProgressTemplate>

</asp:UpdateProgress>

Note : update panel’s update mode is “conditional” and I have registered on_PreRender event of the update panel.

For on_preRender I have implemented this logic :

protected
void upUpdatePanel_PreRender(object sender, EventArgs e)

{


string eventTarget = Request.Params[“__EVENTTARGET”] as
string;


if (string.IsNullOrEmpty(eventTarget) == false)

{


if (eventTarget.StartsWith(this.ID))

{

System.Threading.Thread.Sleep(2000);

LinkButton1.Enabled = true;

LinkButton1.Text = “Enabled Now”;


this.Label2.Text = DateTime.Now.ToString();

BindGrid1();

}

}

}

So I guess nothing special in the code logic, I am just trying to load a grid with hard coded values and with 2 second time interval.

So here is the tricky and most important part of the topic

StringBuilder sb = new
StringBuilder();

sb.Append(“var loopCounter = -1;”);

sb.Append(“function pageLoad(sender, e) {“);

sb.Append(“if (!e.get_isPartialLoad()) {“);

sb.Append(“var refreshPanels = $(\”[id*=\” + \”upUpdatePanel\” + \”]\”);”);

sb.Append(“Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);”);

sb.Append(“var panel = refreshPanels[++loopCounter];”);

sb.Append(“__doPostBack(panel.id, ‘1’);”);

sb.Append(“}function EndRequestHandler() {“);

sb.Append(“var panel = refreshPanels[++loopCounter];”);

sb.Append(“if (panel==null) {“);

sb.Append(“Sys.WebForms.PageRequestManager.getInstance().remove_endRequest(EndRequestHandler);”);

sb.Append(“}”);

sb.Append(“else {“);

sb.Append(“__doPostBack(panel.id, ‘2’);}}”);

sb.Append(“}”);

Page.ClientScript.RegisterClientScriptBlock(typeof(Page), “MYScript”, sb.ToString(), true);

Let me explain in detail.

  • First thing you need to know is that this will be rendered from controls load event
  • I am calling some script after page load event.
  • $(\”[id*=\” + \”upUpdatePanel\” + \”]\”);”)” this part is basically a JQuery selector that selects all divs having id “upUpdatePanel”, which is id of my update panel.
  • After that I am registering an end request event handler, that will be raised when update panel load request is completed.
  • I am looping through all panels and calling __doPostBack of each update panel. __doPostBack will call “upUpdatePanel_PreRender” event.
  • In EndRequestHsndler I am checking if there is another update panel remaining then call its __doPostBack otherwise simple remove end request event handler.

In my page I have dropped 4 user controls

<table
border=”0″ cellpadding=”0″ cellspacing=”0″ width=”100%”>

<tr><td

style=”width: 50%”>

<uc1:WebUserControl1ID=”WebUserControl11″ runat=”server”/>

</td>

<tdstyle=”width: 50%”>

<uc1:WebUserControl1ID=”WebUserControl12″ runat=”server”/>

</td>

</tr>

<tr>

<tdstyle=”width: 50%”>

<uc1:WebUserControl1ID=”WebUserControl13″ runat=”server”/>

</td>

<tdstyle=”width: 50%”><uc1:WebUserControl1ID=”WebUserControl14″ runat=”server”

/>

</td>

</tr>

</table>

This shows page output like


In above screen you can see first panel is being refreshed.


Now first panel has been loaded and now second panel is being refreshed. Same for 3rd and fourth



http://www.4shared.com/folder/Ryz_jgeH/Lazy_Loading.html

you can download code form above link and off course leave a comment if you did like my effort 🙂 

There are not a lot of differences with configuring FBA for SharePoint 2010 compared to 2007, but there are a few.  For instance, SharePoint 2010 no longer supports “classic FBA”, rather forms based authentication is provided through Claims Authentication.  There is also the introduction of the Secure Store Service which is the next-gen of the Single Sign On service of old.

Both of these come into play when configuring Forms Based Authentication.

1 . Configure SQL for membership store

The membership store is still created using the ASP.NET SQL Server Setup Wizard.  This is launched from the .NET 2.0 Framework folder on the server at:

C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql.exe

This wizard will take you thorough the steps and will build out the SQL database for you.




2. Configure Central Admin Web Site to use SQL Membership Provider

SharePoint web sites out of the box are configured to use Active Directory.  So you may be wondering why we’re configuring Central Admin to use FBA when we don’t really want to login in as an FBA user.  Well, we actually don’t want to configure it to to login as a forms user, but we do need to be able to add users from out membership database when configuring site collection admins, and the like.

So all we want to do is tell the Central Admin web application to use our SQL membership provider as well as AD, so when you use the people picker to select users, it will provide results from our membership database.

Open IIS Manager and locate central administration site


Open the Connection Strings Page.  Under Actions menu on the right, select Add… to create a new connection string.  Provide the details for the membership database for the new connection string.



Add Role Provider

Go back to the Web Application page and open up Providers page.  Here we will create a provider for Roles and Users.  Set feature to .NET Roles and click Add… in the Actions pane to add a new role provider.  I called it FBARoleProvider and selected the right type and connection string.



Add Membership Provider

Now set feature to .NET Users and click Add… from the actions pane to add a membership provider.


Select the correct type and connection string, and whatever behaviors you choose.

That’s it for the providers for Central Admin.

To verify that all looks ok, we can check the web.config of the web application.  To get to the right web.config, right-click on the web application under sites, and select Explore.




3 . Configure Secure Store Web Service to use SQL Membership Provider

Everything we did for Central Admin site, we are going to do for theSecurityTokenServiceAppliaation which is in the SharePoint Web Services application.


4. Create Extranet Web Application

Ok, finally we are ready to create our web application (called SharePoint – FBA) that will use FBA authentication.

In Central Admin, Select the Application Management page, and select Manage web applications.  Select New from the ribbon to create a new web application.

Select Claims Based Mode Authentication as Authentication Type. Allow anonymous access and select values for all the other options until you get to the “Enable Forms Based Authentication“.

Add the values we created earlier in the section “Enable Forms Based Authentication” for role and membership provider.



You can specify your custom login page, I will do in later posts.



Click ok and application will be created.

So now our application has been created but we need to configure the same roles and membership providers for this application too, previously we did for only central administration.


So our new web application is here in IIS manager, I will configure it with roles and members


Add a new connection string


Open the .NET Roles page for our web application.  You will receive a warning that the default role provider is not trusted.  There is a pre-configured SharePoint related role and membership is available, so we don’t need to create our own.



Now create some new roles and user for our web application


When u try to open new roles you will see following error message, simple ignore it


We do not have any roles in our database at this point, so let’s create two (StandardUser, SuperUser) by clicking Add… in the actions pane.


Now we need to do the same for .NET Users.  Open the .NET Users page.  You will get a similar warning saying the default is not trusted.  Assuming you don’t let’s add some.  Click Add… from the Actions pane to add users, and assign them roles.



Now create and open the site collection



After creating a new site collection when u open it you will see the following screen


As we have created a user in sql server database and that user is site collection administrator, so use for based authentication.



So you have been logged in with sql server user. That’s it.


Quick steps are one click handlers that performs some operations. Now with SharePoint 2010 and SharePoint designer 2010 it is possible to define quick steps easily.

In this post, we are going to see how we can add new ECB options for list items and also see how to add button in existing ribbon tab. These both options are now possible with SharePoint Designer 2010.

Creating ECB menu option in MOSS 2007 requires creating feature targeting edit control block with CustomActions and deploying it on server.

However there is one limitation for adding control in existing ribbon tab. You cannot have JavaScript function, showing message, disabling controls etc. when creating quick step using Designer 2010. These all can be done via in feature. We will have a detailed post in this topic going forward which is a vast topic.

Open you site and select a list, you will see “New Quick Steps” menu on the top right side.

Let’s go ahead and create one ECB menu option for lists. Open SharePoint Designer 2010. Connect with the site. If you notice, SPD2010 is way different from SPD2007. There are so many differences. SPD2010 looks very clean and clear. It gives very user friendly interface than SPD2007.

Click on Lists and Libraries and choose the list on which you want to create ECB menu item. I have created a new list “Quick Step List”

Double click on the Tasks List to make it open on right side panel, you will see list work flows and custom actions on the top ribbon, we can create new custom actions and work folws from here

When you click on custom action you will see 5 options

I am using “List Item Menu” for this demo because I want to add a quick action on all items page for the list. After clicking you will see the following screen.

Give the name and description. Here you can choose if you have your own page, you can send user to this page with parameters. If you want to initiate any workflow you can do that from here. Or you can also send user to any other url that you wish.

Just to demonstrate i am using Google image and redirecting user to google.com from ECB menu. So mention that URL, use 16 by 16 image of Google, which will be shown to user in the menu item. And finally click on OK. And you are almost done. Remember this image should be in the IMAGES folder under 14 hive. (New structure, not 12 hive like in MOSS 2007)

Save it and move to list item page and create a new entry.

Click on the link and you will be moved to google home page

If you want to edit settings for this quick action, there is a panel for quick actions settings, find you setting and edit it.

Same actions can be added for new disp and edit form, have a try.

Special thanx to SharePointKings for helping me to write this post.

This feature is some of the very much awaited features amongst all new features in SharePoint 2010. People like to edit the item without opening that item in window. Just like ASP.NET grid provides the way of edit and then update by clicking edit button and then updating the record. 

Well, now this was possible in MOSS 2007 as well, but it required little trick, but with SharePoint 2010, it is easy to do that.

Just go to the view settings of any list and then enable the in line editing option.

Check in line editing option and save.

Now move back to list and move mouse cursor near the list item, you will see an “edit” icon against each list item

When u click on the icon, the selected row will be edited and 2 more icons, save and cancel will be displayed.

Make your changes and save. That’s it.

Hi

We all know that there are many out of the box web parts available in MOSS 2007 and now more in SP 2010. Sometimes it is important to see what they offer. Recently I came across to a very good document management related out of the box web part which is relevant documents web part.

This web part was a part of MOSS 2007 and continues to be a part of SharePoint 2010.

This web part is under content rollup section in SP 2010 and under miscellaneous section in MOSS 2007 and these are the configurable properties.

Now I am adding a document

The Relevant Documents web part displays documents that are relevant to the current user. This web part can show following;

Documents last modified by current user
Documents created by current users
Documents checked out by current user

So ultimately it becomes my checked out, my created, and my last modified documents.