After few try, I could come up with the solution of using webpart in asp.net.
For me, with the fresh installation of VS 2010 and SQL 2008 R2, webpart did not work. Following the steps, I solved it:
Webpart use default aspnetdb database. So without configuring database, it was giving me pain. And almost all web help & tutorial did not clear about that.
1.1 Search for aspnet_regsql.exe in your computer. Make sure double click the one which is in .net 4 directory and not in the .net 2 directory
1.2 Select server name. But DO NOT select any database. Leave it to
1.3 By default, it should provide the database name aspnetdb
2.1 Adding the Web Part Components:
Download ajax control toolkit 4.0
put only these 2 files in project bin folder:
Left toolbox of VS 2010, add tab–> chose item — > choose ajax AjaxControlToolkit.dll
2.2 Add ToolkitScriptManager from ajax 4 control toolkits
2.3 Download: Microsoft ASP.NET Futures (July 2007) from:
Install it. Default location should be: C:\Program Files\Microsoft ASP.NET\ASP.NET Futures July 2007\
Copy Microsoft.Web.Preview.dll from C:\Program Files\Microsoft ASP.NET\ASP.NET Futures July 2007\v1.3.61025\3.5 location and paste it into bin folder of project.
2.4 Add tab –> choose item –> browse –> Microsoft.Web.Preview.dll
2.5 Add the following component to your webpage from the asp.net 4 features
- 1 x Web Part Manager
- 2 x Web Part Zones
2.6 Final code should be like this: code
2.7 Display Modes and Personalization
If you see error for the code line: WebPartDisplayMode please add the folowing line in top section of the cs file:
2.8 Configure web.config: source