http://www.codeguru.com/csharp/.net/net_wcf/article.php/c19933/Working-with-NET-Framework-40-Tuples.htm
Returning more than one parameter can be done using tuples
I blog whenever i find things to remember and which are interesting when i am working/learning. I am happy if these experiences are useful to someone else too :) . Please feel free to suggest/correct. These are just out of my experiences . So they may be always a better way to do them ! I view life as a continuous learning experience !!
Friday, August 3, 2012
Tuesday, June 5, 2012
SQL Server Indexes
Clustered Index
Non-Clustered Index
Composite Index
Unique Index (Automatically gets created when you create primary key or unique constraint)
Covering Index
Non-Clustered Index
Composite Index
Unique Index (Automatically gets created when you create primary key or unique constraint)
Covering Index
asp.net mobile
some random notes about mobile development from asp.net videos of scott hansleman
- Add a view port meta tag <meta name ="viewport" content = "width=device-width">
- Fix it on the client
- custom css
- media css
- adapative rendering
- Changing unordered list to dropdown as width is reduced .. use opt group of html
- Dynamically change based on screen size mediaqueri.es
- Fix it on the Client
- Pros
- optimized for the current size
- less duplication of efforts
- Cons
- doesn't consider the differences between mobile and desktop
- inefficient bandwidth usage
- Fix it on the server
- custom mobile views using display modes
- jquery mobile (comes with asp.net mvc 4)
- Make new page with new scripts and css for the mobile page
- Mobile Master Page
- Mobile Child page
- data-role = "content".. tell html5 elements and jquery mobile takes care of the look it has to appear
- data-theme .. can be downloaded from jquery mobile ..
- jquery.mobile.mvc .. nuget package ..
- view switcher .. (mobile version to desktop version & vice versa)
- Ctrl + , to find code or navigate in visual studio ..
- jquery mobile can do data filtering ..
- Pros
- maximum flexibility
- less duplication of efforts
- Cons
- can be repetitive
- device detection can be hard
- Jquery Metro Mobile Theme
- 51degrees.mobi (nuget packaage available)
- Web Sites vs Web Applications
- Offline Capability
- knockout.js for data binding
- static resources for caching .. as cache manifest
Wednesday, May 2, 2012
Wednesday, April 4, 2012
Monday, March 19, 2012
TSQL to LDAP
Script using Master table to create the Link – Step 1
EXEC master.dbo.sp_addlinkedserver @server = N'ADSI', @srvproduct=N'Active Directory Service
Interfaces', @provider=N'ADSDSOObject', @datasrc=N'adsdatasource'
GO
EXEC master.dbo.sp_serveroption @server=N'ADSI', @optname=N'collation compatible', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'ADSI', @optname=N'data access', @optvalue=N'true'
GO
EXEC master.dbo.sp_serveroption @server=N'ADSI', @optname=N'dist', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'ADSI', @optname=N'pub', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'ADSI', @optname=N'rpc', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'ADSI', @optname=N'rpc out', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'ADSI', @optname=N'sub', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'ADSI', @optname=N'connect timeout', @optvalue=N'0'
GO
EXEC master.dbo.sp_serveroption @server=N'ADSI', @optname=N'collation name', @optvalue=null
GO
EXEC master.dbo.sp_serveroption @server=N'ADSI', @optname=N'lazy schema validation', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'ADSI', @optname=N'query timeout', @optvalue=N'0'
GO
EXEC master.dbo.sp_serveroption @server=N'ADSI', @optname=N'use remote collation', @optvalue=N'true'
GO
Step 2 – Set to Domain Admin account
Then Query
SELECT *
FROM OPENQUERY(ADSI,
'SELECT
mail
FROM
''LDAP://DC=orgname,DC=org''
WHERE
objectCategory = ''Person''
AND
objectClass = ''user''
AND
sAMAccountName = ''***''')
Tuesday, March 13, 2012
SSRS URL parameters
This article shows you some of the most common reporting parameters to use in Microsoft SQL Server Reporting Services.
When you go to the [http://reportserver/reportserver/foldername/reportname]
The last command in the url is &rs:Command=Render
You can add some other commands as follows:
&rc:Parameters=Collapsed * This is a very important parameter to know as more often than not, the report data doesn't update immediately unless parameters are changed, and your report may show cached data if this is not set.&rc:StyleSheet=MyCustomStyle
ReportServer Parameters:
If you add ?/FolderName/ReportName after the [http://servername/reportserver] you can run the report.
If you add ?/FolderName/ReportName after the [http://servername/reportserver] you can run the report.
The same applies if you want to list the reports, then just type ?/FolderName after the [http://servername/reportserver].
This is commonly used when the user only has permissions at the folder level, not the root level.
Tuesday, March 6, 2012
Friday, February 24, 2012
Calling Page Methods
Creating a Page method (ScriptMethod) within an ASCX user control using AJAX, JSON, base classes and reflection
Excellent Article
http://www.chadscharf.com/index.php/2009/11/creating-a-page-method-scriptmethod-within-an-ascx-user-control-using-ajax-json-base-classes-and-reflection/
Excellent Article
http://www.chadscharf.com/index.php/2009/11/creating-a-page-method-scriptmethod-within-an-ascx-user-control-using-ajax-json-base-classes-and-reflection/
Thursday, February 23, 2012
Sunday, February 12, 2012
State Pattern
I am learning about design patterns in depth these days. Amazed by the solutions they give .. Some patterns like abstract factory , factory made sense to me but could not find immediate application to my code .. so could not get that uahaa feeling ;) When i read about the state pattern http://blog.raffaeu.com/archive/2011/02/13/state-pattern-using-c-part-01.aspx .. i found an immediate use for this in all my code. I realized how my code is tightly coupled all these days .. Implemented this and now i have a happy feeling .. I learned something new and implemented it . .................. :) :)
I have a class which as states such as new edit view .. I moved all the logic related to this states using this pattern :)
I have a class which as states such as new edit view .. I moved all the logic related to this states using this pattern :)
Monday, February 6, 2012
Friday, February 3, 2012
Hidden Field in a disabled panel or div
I was working on a form for a project. The form needs to be edited or viewed. For view i disabled all the panels or divs.But it has some links which needs to work. The links used hidden fields inside the disable panel.
Then i sudden found the links are not working as the hidden fields are not retaining the values as they normally do. Then a google search on this gave me this link .. which saved my time a lot.. It seems asp.net does not maintain view state for hidden fields in a disabled panel. So need to get around this by some way :)
http://www.codewrecks.com/blog/index.php/2010/04/15/asp-net-and-an-hiddenfield-inside-a-disable-panel/
Then i sudden found the links are not working as the hidden fields are not retaining the values as they normally do. Then a google search on this gave me this link .. which saved my time a lot.. It seems asp.net does not maintain view state for hidden fields in a disabled panel. So need to get around this by some way :)
http://www.codewrecks.com/blog/index.php/2010/04/15/asp-net-and-an-hiddenfield-inside-a-disable-panel/
Monday, January 30, 2012
Getting Class Name and Method name using reflection
To get the current method and class name in which the code is executing, we can use reflection.
Method Details
Method Details
System.Reflection.MethodBase.GetCurrentMethod().Name,
Class Details
System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.Name
Handy to log the errors ..
Thursday, January 26, 2012
Error :Attempted to access an unloaded appdomain
Attempted to access an unloaded appdomain. (Exception from HRESULT: 0x80131014)
This occurs when we try to open two different connections in the same Transaction Scope . Use Transaction Scope.Suppress for one of the connection if you are not performing any transaction in one of the connection.
But if you are making transactions in both of the connections as a single one ... i need to study further about this ... probably you have to open a new transaction under the main one .. will verify later
This occurs when we try to open two different connections in the same Transaction Scope . Use Transaction Scope.Suppress for one of the connection if you are not performing any transaction in one of the connection.
But if you are making transactions in both of the connections as a single one ... i need to study further about this ... probably you have to open a new transaction under the main one .. will verify later
Dynamic Grouping in SSRS
To achieve dynamic grouping in SSRS , i.e you group by a parameter chosen by the user.
1) Send the group by parameter to the stored procedure/sql statement and let SQL handle the grouping by case statement
Ex :
SELECT case(@groupby)
when 'gender' then dummy.Gender
when 'race' then dummy.Race
when 'district' then dummy.District
end "groupbyfield",
count(*)"Count",
FROM dbo.dummy
WHERE DummyDate BETWEEN @startdate and @enddate
GROUP BYcase(@groupby)
when 'gender' then dummy.Gender
when 'race' then dummy.Race
when 'district' then dummy.District
end "groupbyfield"
2) Sort by the "groupbyfield" in SSRS.
1) Send the group by parameter to the stored procedure/sql statement and let SQL handle the grouping by case statement
Ex :
SELECT case(@groupby)
when 'gender' then dummy.Gender
when 'race' then dummy.Race
when 'district' then dummy.District
end "groupbyfield",
count(*)"Count",
FROM dbo.dummy
WHERE DummyDate BETWEEN @startdate and @enddate
GROUP BYcase(@groupby)
when 'gender' then dummy.Gender
when 'race' then dummy.Race
when 'district' then dummy.District
end "groupbyfield"
2) Sort by the "groupbyfield" in SSRS.
Wednesday, January 25, 2012
Generating Enums from Database for Lookup Tables
These are the two links i found for this problem.
http://erraticdev.blogspot.com/2011/01/generate-enum-of-database-lookup-table.html
http://idisposable.co.uk/2010/03/using-t4-to-generate-enums-from-database-lookup-tables/#viewSource
I implemented the second one as i found it easier and more flexible in naming the enums differently from the database look-ups.I struggled with this for a few hours as i did not one thing . i.e When we add t4 template to VS make sure that it in the properties of the t4 file the custom tool is set to "TextTemplatingFileGenerator". The default one is the text processing .. so i could not see the enum file .. Finally after some time i could identify this.
This is really nice because you find your code more readable while not loosing flexibility of look-ups. Every time you have a new look-up you have to regenerate the t4 template and build your project.
Thanks to people who wrote these templates :). It made my life easier.
http://erraticdev.blogspot.com/2011/01/generate-enum-of-database-lookup-table.html
http://idisposable.co.uk/2010/03/using-t4-to-generate-enums-from-database-lookup-tables/#viewSource
I implemented the second one as i found it easier and more flexible in naming the enums differently from the database look-ups.I struggled with this for a few hours as i did not one thing . i.e When we add t4 template to VS make sure that it in the properties of the t4 file the custom tool is set to "TextTemplatingFileGenerator". The default one is the text processing .. so i could not see the enum file .. Finally after some time i could identify this.
This is really nice because you find your code more readable while not loosing flexibility of look-ups. Every time you have a new look-up you have to regenerate the t4 template and build your project.
Thanks to people who wrote these templates :). It made my life easier.
Thursday, January 12, 2012
Required Field Validator for Dropdown
Set the RequiredFieldValidator.InitialValue property to the value of your prompt item like so:
<asp:dropdownlist id="DropDownList1" runat="server" autopostback="True" onselectedindexchanged="DropDownList1_SelectedIndexChanged"> <asp:listitem value="-1">Select Option</asp:listitem> <asp:listitem>A</asp:listitem> <asp:listitem>B</asp:listitem> <asp:listitem>C</asp:listitem> </asp:dropdownlist> <asp:requiredfieldvalidator id="RequiredFieldValidator1" runat="server" errormessage="RequiredFieldValidator" controltovalidate="DropDownList1" display="Dynamic" initialvalue="-1" setfocusonerror="True"> </asp:requiredfieldvalidator> <asp:button id="Button1" runat="server" text="Button" />
Subscribe to:
Posts (Atom)