Thursday, May 29, 2008
I recently try Dynamic Data on ASP.NET 3.5 Extensions CTP.
The most thing that impress me is an idea of Dynamic Control /Field.
<asp:DynamicControl runat="server" DataField="EmailAddress"/>
So you can just simple define Dynamic Field in your Grid View and it will rendered into particular template (Include Edit Template) based on data type of your value.
You can define your template to have validation control or even can you 3rd party control such as telerik.
Here is How you can tell dynamic control to render based on particular template or even BLOB/Image Type as well.
UIHint is where you define your template.
You can create whatever for your template name and just put "_Edit" for edit mode.
Just see the sample in under FieldTemplates of your Dynamic Data Project
I heard some developers asked about this question "If you can create a static class, Why do we need to create a Singleton Class ?"
I think the answer is straight forward.
Singleton Pattern is a pattern that will make sure there is only 1 instance. on the other hand It will make sure that developers will not be able to another instance.
Static Class will share your instance through your application. But this static class will not make sure that it will only be 1 instance of your class. Other developer which don't know where you put your static instance will able to create the new instance... and It will be any duplication and waste of resources.
Here is very simple Singleton pattern.
Wednesday, May 14, 2008
As you can see in Web Developer tool, there is a lot of request happening on the background.
The first thing you need to do before combining Ajax scripts, You need to know what scripts are being used by your pages.
Add this on your pages to detect what scripts are being used.
After that Copy all the Script References which is written by Script Reference Profiler.
And Paste it into Script Manager Composite Scripts.
And as a results you can decrease the number of request and traffic for this scripts.
PS: The ScriptReferenceProfiler control is not part of the Beta installation, and you must install it separately. Download this http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=aspnet&ReleaseId=13356.
Wednesday, May 7, 2008
If we use CSS Friendly,
This happen if I put GridView Under Update Panel without table.
But finally I found that in my master page there is this strange tag.
<a name="body" />
After remove this, Everything works fine.
Here is the reference.
The most explanation that I found so far is this
=====From Lewis =====
I found that this error is caused by having a a html ‘form’ element somewhere inside the postback html.
After taking out the form tags (and any asp.net controls generating them) from the updatePanel’s contentTemplate, the error went away.
However , I still don't understand If I put your GridView outside update panel and keep EnableSortingAndPagingCallbacks="True"
I think this is cause by CSS Friendly, because If I take the CSS Friendly out for GridView, It works fine
Any comment ?
Tuesday, May 6, 2008
There are several ways to debug your Linq to sql
- Sql Server Profiler
But How about if you share your Sql Server with others such as staging DB ?
It will be nightmare.
- DataContext Command
But How about if you don't want to write any debug code ?
- LINQ to SQL Debug Visualizer
I think this is the best way to debug your LINQ to SQL.
You can use .NET Debugging Mode
And Click small magnifying glass in the expression above, It will launch the LINQ to SQL debug visualizer to inspect the raw SQL that the ORM will execute based on that LINQ query:
Click "Execute" button, you can even test out the SQL query and see the raw returned results that will be returned from the database:
Installing SQL debug Visualizer :
- Download Linq to Sql Debug Visualizer http://www.scottgu.com/blogposts/linqquery/SqlServerQueryVisualizer.zip - (From Scott Gu Blog)
- Copy from \SqlServerQueryVisualizer\bin\Debug\SqlServerQueryVisualizer.dll
- Copy to C:\Program Files\Microsoft Visual Studio 9.0\Common7\Packages\Debugger\Visualizers
You may start debug your LINQ...