Apr 6 2008

Problem in SQL Server Session State - ASP.NET 3.5

*** Updated - April 7 2008  ***

I played a little bit with the command line I am using to install the SQL Server Session State database and it seems to work fine: To register the database for the SQL Server Session State on ASP.NET 2.0 or ASP.NET 3.5:

aspnet_regsql -C "Data Source=.;Integrated Security=True" -ssadd -sstype c -d SessionStateDB

In addition to this, you might need to grant access to: 'NT AUTHORITY\NETWORK SERVICE' on your database

Hope this solves your problem as it solved mine!!
Regards 

*** Updated - April 7 2008  ***

 

I enabled a database with the schema tables used for SQL Server Session State as follows:

aspnet_regsql -S .\ -d aspnetdb -E -sstype c -ssadd

 

Then in the web.config file, I enabled SessionState as follows:

<sessionState 
   
allowCustomSqlDatabase="true"
   
mode="SQLServer"
   
sqlConnectionString="data source=.\;initial catalog=aspnetdb;trusted_connection=true"
   
timeout="20" />

 

When I run my page, I recieve the following exception:

Unable to use SQL Server because ASP.NET version 2.0 Session State is not installed on the SQL server. Please install ASP.NET Session State SQL Server version 2.0 or above.

 

It sounds strange, I am using the 2.0 version of the script!! Any ideas?

Thanks

Tags: , , , ,

Apr 3 2008

Encrypting Connection Strings

Category:Bil@l @ 17:35

I found this very important link that you should have a look at when you want to encrypt configuration sections in your application's web.config file. It helps not only with encrypting ConnectionStrings but also gives an idea on how to encrypt other configuration sections, how to create key containers, export them, etc ...

 

Strongly recommended link: http://blogs.vertigosoftware.com/snyholm/archive/2005/12/16/1746.aspx

 

HTH,
Regards

Tags:

Apr 3 2008

Kigg Starter Kit

Category:Bil@l @ 07:22

A new starter kit is published on www.codeplex.com that is developed with ASP.NET MVC Framework, LINQ to SQL and ASP.NET AJAX!

Check it out here: http://www.asp.net/downloads/starter-kits/Kigg/

 

Hope it helps,
Regards

Tags:

Mar 29 2008

Ready-Made Delegates in .NET 2.0

Category:Bil@l @ 22:31

Sometimes while writing your code you need to create new delegates to meet your specific project requirements to call specific methods. Before directly opening a new CS or VB class and start adding new delegates, make sure to check the read-made delegates introduced by .NET 2.0. Some of these are listed here:

 

.NET 2.0 Read-Made Delegates

1. delegate Boolean Predicate<T>(T obj);

This is a delegate that can hold a reference to a method that takes as input a parameter of type T and returns boolean.

 

2. delegate void Action<T>(T obj);

This is a delegate that can hold a reference to a method that takes as input a parameter of type T and returns nothing.

 

3. delegate void MethodInvoker();

This is a delegate that can hold a reference to a method that takes no input parameters and returns nothing.

 

In .NET 3.5 new delegates were added:

delegate void Action();

delegate void Action<T1, T2>(T1 arg1, T2 arg2);

delegate void Action<T1, T2, T3>(T1 arg1, T2 arg2);

delegate void Action<T1, T2, T3, T4>(T1 arg1, T2 arg2,T3 arg3, T4 arg4);

delegate TResult Func<TResult>();

delegate TResult Func<T, TResult>(T arg);

delegate TResult Func<T1, T2, TResult>(T1 arg1, T2 arg2);

delegate TResult Func<T1, T2, T3, TResult>(T1 arg1, T2 arg2);

delegate TResult Func<T1, T2, T3, T4, TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4);

 

The above delegates are self explained. So now, when you need a new delegate, check the existing ones before creating your own! The above delegates are all present inside the System namespace.

 

Hope this helps,
Regards

Tags:

Mar 28 2008

Microsoft - LebDev Visual Studio and Windows Server 2008 Community Launch

Category:Bil@l @ 21:54

Today we had the LebDev user group version of the Community Launch for Visual Studio 2008 and Windows Server 2008 at the Gefinor - Rotana Hotel - Hamra. The session started at 6 and lasted for 3 hours.

Maral Topalian delivered a session on Windows Server 2008

I presented a demo-ish session by developing a simple blog engine using LINQ to SQL, AJAX, ASP.NET 3.5, VS 2008. You can download the PPTX and code from here: Presentation (https://bhaidar.net/cs_files/MSFT-Launch-2008.zip) and Sample code(https://bhaidar.net/cs_files/MSFTLaunch2008.zip).

Wessam Zeidan (www.wessamzeidan.net) then delivered another demo-ish presentation on Silverlight 2.0, WPF, and ADO.NET Data Services.

The next stop is the official Microsoft Launch on April 30! I will be delivering something, not sure yet what it is :)

 

Hope this helps,
Regards

Tags:

Mar 27 2008

Intellisense with Client-side Proxy Classes in AJAX

Category:Bil@l @ 22:22

I was trying to find out how to enable JavaScript Intellisense for webservices' client-side proxy classes when we are accessing client-proxy classes in external JS files?

I couldn't find a simpler solution than to:

  1. Run the application
  2. Download the client-side proxy class
  3. Save the content to a JavaScript file as the name of the Webservice and the extension of .js
  4. Add a /// <reference path="MyProxy.js" /> to the external JS file
  5. Intellisense enabled!

Is there an easier way of doing the same?

 

Regards

Tags:

Mar 27 2008

AJAX Client Library Presentation @ Microsoft Office

Category:Bil@l @ 17:37

Yesterday I delivered a session on ASP.NET 2.0 AJAX Extensions 1.0 - Client Library.

This presentation was part of a two-days free training Wessam Zeidan (www.wessamzeidan.net) and I delivered for a selected group of the Lebanese developers that are part of the LebDev.NET User Group members.

 

You can download the pptx file from here (https://bhaidar.net/cs_files/Ajax-Basics-Client-Library.zip).

As for the sample codes, you can follow the source code that ships with the book: AJAX in Action (http://www.manning.com/gallo/). I have used the same code to show some samples!!

 

Hope this helps,
Regards

Tags:

Mar 27 2008

Client Application Services Part 3

Category: ASP.NET 3.5 | Windows FormsBil@l @ 14:25

My third article in the series of articles on Client Application Services is now published on www.aspalliance.com. This is the last article in the aforementioned series! Hope you enjoy it! You can check it at: Client Application Services Part 3 (http://aspalliance.com/1597_Client_Application_Services__Part_3).

Make sure to read the previous two parts before going on with this new part! Here are the links for Parts 1 and 2.

 

  1. Client Application Services Part 1 (http://aspalliance.com/1595_Client_Application_Services__Part_1)
  2. Client Application Services Part 2 (http://aspalliance.com/1596_Client_Application_Services__Part_2)

 

Hope this helps,
Regards

Tags: ,

Mar 27 2008

Nested MasterPage Not Firing Page_Load Event

Category: ASP.NET 2.0 - General | ASP.NET 3.5Bil@l @ 11:42

I faced a situation today where I am trying to attach to the page_load event of a child nested master page to load some data on the master page itself. The event was not firing at all. Later on I figured out that the AutoEventWireup property on the Page directive is false!!!

Seems by default when you create a nested master page, its AutoEventWireup property is set to false! What you need to do is just make it true!

 

Hope this helps!

Regards

Tags: ,

Mar 27 2008

RowIndex inside ListView_ItemDataBound event

Category:Bil@l @ 10:10

If you need to access DataKeys of a ListView from inside the ItemDataBound you need to use the ListViewDataItem class. The ListViewDataItem class represents an individual data item in the ListView control. Every data item refers to a record in the data source.

The trick is to use the ListViewDataItem.DisplayIndex property! This property returns the index of the currently bound row inside the ListView collection of items.

A sample code could help more:

protected void PostList_ItemDataBound(object sender, ListViewItemEventArgs e)
{
    // Get the listview
    ListView listView = (ListView)sender;

    //Get the item object.
    ListViewDataItem dataItem = (ListViewDataItem)e.Item;

    // Only data items are allowed
    if (e.Item.ItemType != ListViewItemType.DataItem) return;

    // Get the PostID from the ListView's datakey
    int postID = int.Parse(listView.DataKeys[dataItem.DisplayIndex].Value.ToString());

}

 

The ListView DataKeyNames had a value of "PostID" which represents the primary key column in the data table.

First of all you cast the e.Item property to an instance of ListViewDataItem, then using the DisplayIndex property you can access the DataKeys of the currently bound row!

 

Hope this helps,
Regards

Tags: