Monday, August 29, 2011

Use regular expressions to save time.

Replace in files...

Utils.GetConfigValue\({"[a-zA-Z0-9_ ]+"}\)

to

System.Configuration.ConfigurationManager.ConnectionStrings\[\1\]

Wednesday, August 3, 2011

Sorting entries in config appsettings.

   How to sort AppSettings without manually missing any keys or important information.
Code Snippet
  1.   private void WriteAppSettingsToFile(string filename)
  2.     {
  3.  
  4.         List<string> lstConfigKeys = new List<string>();
  5.         foreach (string appKey in ConfigurationManager.AppSettings.AllKeys)
  6.         {
  7.             lstConfigKeys.Add(appKey);
  8.         }
  9.  
  10.         lstConfigKeys.Sort();
  11.  
  12.         using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\" + filename + ".txt"))
  13.         {
  14.             foreach (string key in lstConfigKeys)
  15.             {
  16.                 file.WriteLine(string.Format("'{0}', -- {1}", key, ConfigurationManager.AppSettings.Get(key)));
  17.             }
  18.         }
  19.     }

You can modify the code to write the keys in the form of   . Then copy and paste the output to your actual config file. You have all the keys in sorted order. 

Monday, June 20, 2011

How to generate dynamic report.

Below is the code that I had written for generating dynamic report. It takes few parameters and generates the reports for a particular frequency.



using System;

using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;


namespace Reports.DynamicReports
{
///
/// Summary description for GetDynamicFrequencyReport.
///

public class GetDynamicFrequencyReport : System.Web.UI.Page
{
protected System.Web.UI.WebControls.PlaceHolder plResults;


ReportDS rds;
DataSet ds;


private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here

// Put user code to initialize the page here

int intid;
string strSourceid ;
int intCount=0;
DateTime dtFromDate;
DateTime dtToDate;
string strFrequency;

string strSourceFromDate;
string strSourceToDate;
string strSourceFrequency;

int inti;

if (Request["id"]!=null)
{
strSourceid = Request["id"];
strSourceFromDate = Request["fromdate"];
strSourceToDate=Request["todate"];
strSourceFrequency = Request["frequency"];

try
{
intid = int.Parse(strSourceid);
dtFromDate = DateTime.Parse(strSourceFromDate);
dtToDate = DateTime.Parse(strSourceToDate);
strFrequency = strSourceFrequency;

rds = new ReportDS();
ds = rds.GetDynamiFrequencyReport(intid,dtFromDate,dtToDate,strFrequency);

if (ds != null && ds.Tables.Count > 0 )
{
intCount = int.Parse(ds.Tables[0].Rows[0][0].ToString());


for (inti = 1; inti <= intCount ; inti++) { DynamicTables(inti); } } } catch(Exception ex) {} } } private void DynamicTables(int inti) { int intLabelTable; int intGridTable; intLabelTable = (inti * 2 )-1; intGridTable = (inti * 2 ); AddToPlaceHolder(CreateLabel(ds.Tables[intLabelTable].Rows[0][0].ToString())); AddToPlaceHolder(CreateDataGrid(ds.Tables[intGridTable])); } private void AddToPlaceHolder(Control oControl) { try { if (oControl != null) { plResults.Controls.Add(oControl); } } catch(Exception Ex) { } } private Label CreateLabel(string sText) { Label oControl = new Label(); oControl.Text = sText; oControl.Font.Name = "Verdana"; oControl.Font.Size = 11; oControl.Font.Italic = true; oControl.Font.Bold = true; return oControl; } private DataGrid CreateDataGrid(DataTable dt) { DataGrid oControl = new DataGrid(); // //
//
//

//
//
//



oControl.BorderColor= Color.Black;
oControl.BorderStyle = BorderStyle.None;
oControl.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(1);
oControl.BackColor = System.Drawing.Color.FromArgb(247,247,247);
oControl.CellPadding = 4;
oControl.Font.Name = "Verdana";
oControl.Font.Size = 9;


//

oControl.AlternatingItemStyle.BackColor = System.Drawing.Color.FromArgb(235,235,235);

//


oControl.PagerStyle.ForeColor = System.Drawing.Color.FromArgb(51,00,153);
oControl.PagerStyle.BackColor = System.Drawing.Color.FromArgb(255,255,204);



oControl.GridLines= GridLines.Vertical;
oControl.CellPadding = 3;



oControl.FooterStyle.ForeColor=Color.Black;
oControl.FooterStyle.BackColor=Color.LightGray;

oControl.AlternatingItemStyle.BackColor =Color.Gainsboro;
oControl.ItemStyle.ForeColor = Color.Black;

oControl.HeaderStyle.Font.Bold = true;
oControl.HeaderStyle.ForeColor=Color.White;
oControl.HeaderStyle.BackColor=Color.Blue;

oControl.DataSource = dt;


oControl.DataBind();

return oControl;
}


#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion
}
}

Friday, May 6, 2011

Exciting effect.

I wanted to write a simple exciting effect for my blog at XO. I have decided to eliminate a bunch of lines of crappy code and put decent code which is simple and effective.

http://jsfiddle.net/vijayphani/reRJP/

Thursday, April 7, 2011

tableless layout with div

http://www.w3.org/2002/03/csslayout-howto

Thursday, March 24, 2011

How to find time difference between two dates in oracle.

select numtodsinterval(last_upd_dt - created_dt,'day') time_difference from dates;

Thursday, March 10, 2011

How to create a border with different images in css3.

http://www.css3.info/wp-content/uploads/2007/09/multiple-backgrounds-example.html

Tuesday, March 8, 2011

One of the best tech videos that I have seen.

http://blogs.msdn.com/b/davidebb/archive/2010/10/05/introducing-nupack-the-smart-way-to-bring-bits-into-your-projects.aspx



This is the best tutorial to learn a lot of stuff.

http://www.asp.net/mvc/tutorials

Thursday, March 3, 2011

Why do page methods have to be static.

I need to do some research on this and do a good post.

Thursday, February 24, 2011

Free profiling tool for .net

While working with EF today, I was going through blogs and EF performance issues. I stumbled upon a open source performance profiler called slimtune.

http://code.google.com/p/slimtune/

I will check it and post an update. I dont have to buy ants profiler.

Wednesday, February 23, 2011

How to enable CSS 3.0 Intellisense in vs2008.

Today I was trying out CSS 3.0 and the document was not getting formatted because the new css 3.0 tags are not getting recognized.

To enable css 3.0 you need to find the key "{A764E895-518D-11d2-9A89-00C04F79EFC3}"

Note: You may many matching keys but look for the one which shows schemas


Add a new key Schema 5 and add 2 string values File and Friendly name and set the values to

css30.xml and CSS 3.0.

Now take the css30.xml and copy to the folder below.

C:\Program files\Microsoft Visual Studio 10.0\Common7\Packages\1033\schemas\CSS


Download the xml here (For some reason it is not allowing me to add the css30.xml).

Close your visual studio and open it. when you open a css file it should pull the drop down with friendly name.


Now you don't see an error under border-radius.


Stack Overflow

Today I posted a question on Stack overflow and I want to see the potential of the website in getting answers.


http://stackoverflow.com/questions/5095658/continuous-integration


also found few links of learning

http://net.tutsplus.com/tutorials/asp-net/asp-net-from-scratch-mvc/
http://msdn.microsoft.com/en-us/library/bb386876.aspx (Getting started with Entity Framework).
http://net.tutsplus.com/category/tutorials/javascript-ajax/page/4/

Hopefull will post an article on Entity Framework soon.




Extension to website.

http://www.apture.com/


Found a decent website that can automatically content to your website. Need to research on this website today.

Friday, February 18, 2011

Build a registration form.

I wanted to build a nice registration form and see how it looks. I tried to use html5 and css3 to round the corners of input box. I will try it and let you know after it works.



http://net.tutsplus.com/tutorials/html-css-techniques/html-5-and-css-3-the-techniques-youll-soon-be-using/


A good site that shows how to skin your site.

How to put a border to div.

Yesterday, in my code I was not happy with putting 2 divs, one inside an another to mimic the mouse hover effect. I will try and find something that could be done with 1 div. I will post the code once I find the solution.


****Update ****

The code is a lot cleaner and with one div I could get the job done. You don't need 2 divs to mimic the nice effect.

http://jsfiddle.net/vijayphani/Pd3GN/10/


Thursday, February 17, 2011

How to make at good tooltip and use it across projects

Today I am going to put some effort in writing a good tooltip and also make a good layout for my project.


I will be writing something like this. I will also publish the code in jsfiddle.net.






How to test the code written in my blogs.

Sometimes as developers we face lot of challenges and also people would be frustrated with the output that we give. Bold statement but true. Today morning, I posted a blog and I thought I did a good job and posted the code online I was happy with it and I am done. I tried to show this to my friend and with lot of excitement. In fact the blog looked ugly and no one would want to go through the lengthy code. Now that is the obvious problem. I google for a while to convert the html tags to > and < and then posted the code. It still looks ugly.

For every problem there will be a solution and all you have to do is ask, explore or be criticized that is when you will explore or try somethings. My friend suggested that I post the code to jsfiddle.net. It is more readable and people can actually play with the code without leaving the browser.

http://jsfiddle.net/vijayphani/Pd3GN/

It does feel good because with jsfiddle you can tidy your code and at the same time run your code. Give it a shot and you will love it.

Rounded Corners

It was interesting to try and create rounded corners to display content in HTML. Since html5 is gaining popularity and css3 supports border-radius, I thought I should try to create something interesting for myself.

The code is below for page.
----------------------------

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RoundedCorners.aspx.cs"
Inherits="CoolUI.RoundedCorners" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

<script src="Scripts/jquery-1.4.4.min.js" type="text/javascript"></script>

<link href="Styles/CoolUI.css" rel="stylesheet" type="text/css" />
<title></title>

<script type="text/javascript" language="javascript">
$(function() {
$('#divchi').mouseenter(function() {

$('#divpar').css("background-color", "#FF0000");
});

$('#divchi').mouseleave(function() {
$('#divpar').css("background-color", "#FFFFFF");
});
});


</script>

</head>
<body>
<form id="form1" runat="server">
<div id="divpar" class="divpar" style="height: 204px; width: 204px;">
<div id="divchi" class="divchi" style="height: 200px; width: 200px; position: relative;
top: 2px; left: 2px">
<table cellspacing="2" cellpadding="2" width="100%">
<tr>
<td>

<span class="spntitle">Welcome</span>
</td>
<td>
</td>
</tr>
<tr>
<td colspan="2" valign="top">
<p>
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis
egestas.Donec eu libero sit amet. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis
egestas.Donec eu libero sit amet. egestas.Donec eu libero sit amet ristique senectus et netus </p>
</td>
</tr>
<tr>
<td>
<span class="spnfoot">All right reserved.</span>
</td>
<td>
</td>
</tr>
</table>
</div>
</div>
</form>
</body>
</html>

The ccs for the page is
--------------------------

body
{
background: #CCCCCC;
font-family: Verdana;
font-weight: lighter;
font-size: 11px;
}

.divpar
{
background-color: #FFFFFF;
border-radius: 8px 8px 8px 8px;
}
.spntitle
{
font-family: Verdana;
font-weight: lighter;
font-size: 12px;
color: #CCCCCC;
}

.spnfoot
{
font-family: Verdana;
font-weight: lighter;
font-size: 12px;
color: #CCCCCC;
}

.divchi
{
background-color: #FFFFFF;
border-radius: 8px 8px 8px 8px;
}



Testing it in different browsers

1. Google Chrome
------------------


2. Internet Explorer
--------------------


3. Mozilla Firefox
------------------

4. Opera
---------
When you hover your mouse over the content the
border gets highlighted.



Display in opera.


At the time of this article the browser versions are

1. IE 7.0
2. Opera 11.01
3. Firefox 3.6.13
4. Google Chrome 8.0.522.

Once css3 is completely supported in all the browser the display will be
uniform across browsers.

Till then have fun.



Monday, February 14, 2011

Test API from Web. APIGee

Today I was talking to one of my friend and he showed me the simplicity in APIGee.com. This has few free APIs to test.

An interesting find is that in HTML5 we can use canvas to display graphs and other interesting things.

Friday, January 28, 2011

HTML ipsum

While learning about jquery, I stumbled upon a new site called http://html-ipsum.com/. I used to goto lorem ipsum and copy code and then format it to my need. But this site already does a bunch of things for me. Check it out you wont be disappointed if you are a UI designer.

Wednesday, January 12, 2011

How to test you code in different IE version browsers at the same time.

Today, I have decided to learn jQuery. They got my new computer yesterday and I am very excited about the fact that I can learn UI again. After watching a couple of jQuery videos, It is more exciting to know that there is a tutorial called "jQuery for absolute beginners". While watching these videos, I found that the best tool to test your code in multiple IE version is "IETester." Played with it for a while and like it a lot.

Tuesday, January 11, 2011

Learning JQuery

Today I haves started to learn jQuery. Had been thinking for a while but, never was able to do some solid coding. A friend of mine refered me to this site. http://jsfiddle.net/


1. The best way to learn jQuery is download a cheat sheet, and understand the document.
2. Get Webdeveloper firefox extension and learn how to inspect elements.
3. Learn how to load jQuery to any page you are looking at. (It is little complicated. Goto to the link and bookmark it.

http://www.learningjquery.com/2009/04/better-stronger-safer-jquerify-bookmarklet)

Clicking on that link while viewing any page will inject jQuery in that page and you can use webDeveloper to inspect elements using JQuery.

4. Open JSFiddle and then create your own files.

Whatever be the learning curve, do the one that suits you.

Monday, January 10, 2011

Learning MVC2, Nerd Dinner.

Today, I have decided to learn MVC after leaving from Sogeti. Till yesterday it was very hectic trying to see what is crashing our server when we add 2 processors on a virtual machine. After multiple permutations and combinations of errors we couldn't resolve the issue.

Well While learning MCV2, I stumbled up 2 website that are funny.

http://www.sadtrombone.com/

and

http://instantrimshot.com/

These sounds could be used during presenation. It would be nice to see how the audience would react.

Monday, January 3, 2011

ASP.NET MVC Jquery Grid

http://haacked.com/archive/2009/04/14/using-jquery-grid-with-asp.net-mvc.aspx