Monday, October 29, 2007

How to make a TreeView Control in ASP.Net 1.1 and populate it from the database.

As Treeview control is not a control in ASP.Net1.1 so we have to use a third party control, to compensate for that.
The following article will help you in that:-
Downloaded Web-Controls from one of links below:

1)http://msdn.microsoft.com/library/default.asp?url=/workshop/webcontrols/behaviors/library/treeview/treeview.asp
2)http://msdn.microsoft.com/archive/en-us/samples/internet/asp_dot_net_servercontrols/webcontrols/(This has the installable).

a)After running the installable, we get a folder named IE Web Controls in
C:\Program Files.
b)Then execute the Build.bat file ( A folder named Build will be created).
c)Copy the dll to your Project Bin Folder.
d)Since we have already copied the Web Control(dll) to our Project Folder(BIN)
e)In the Solution Explorer(.net) add a new Reference, a Dialog Box will open.
Browse to the Microsoft.Web.UI.WebControls (which is residing in the BIN folder
of your current project)by clicking the Browse Button.
f)Now create a folder named webctrl_client under c:\inetpub\wwwroot and under
webctrl_client create a folder named 1_0.
g)In the folder 1_0 copy the content of the Runtime under C:\Program Files\IE Web
Controls\build.

Now you are ready to use the Treeview control in your Project.
Add the following namespaces in your webpage where you shall be using the treeview control:
import namespace="Microsoft.Web.UI.WebControls"
Register TagPrefix="Treeview1" Namespace="Microsoft.Web.UI.WebControls"
Assembly="Microsoft.Web.UI.WebControls"

Add the following tag in the HTML part:
VIEW1:TREEVIEW id=Treeview1 runat="server" Width="194px" Height="185px" BackColor="LavenderBlush" BorderStyle="Ridge" AutoPostBack="True" ExpandLevel="1" Enableviewstate="true" onselectedindexchange="cal" NAME="Treeview1">Populating the Treeview Control from the database:
Write the following in Public Fuction Cal()
Create a new node for the tree-
Dim node as TreeNode()
chan_desc=DS1.Tables("Channel").Rows(i).item("channel_desc")
chan_id=DS1.Tables("Channel").Rows(i).item("channel_id")
node.Text=chan_desc
node.Id=chan_id
noder.Nodes.Add(node)

Repeat the above steps to add as many nodes you want.
The next node will be added by-
node.Nodes.Add(node1)

That is it, now you are ready to incorporate Treeview Control in ASP.Net 1.1.

Thursday, October 18, 2007

Using StyleSheets in asp.net.

If you are a novice, how will you design your pages in asp.net.You will choose the colors, font and all the other designing aspects from the properties box of that particular web control.But do you think that this is a nice idea.No, it is not.
For making it easy, generous and to bring a uniformity to our application, we use style sheets.
Using style sheets is a comman way of designing our webforms.

So, how to use them in asp.net. This is the way:-
Steps:
1)Add the following tag in the HTML part of your page -
link rel="stylesheet" type="text/css" href="styles/style.css"

Note: I have used it within the 'HEAD' tag.
2)Create a new folder--- styles in under your project.
3)Within that folder, create a .css file - Style.css(Add new item)
4)Add some classes in that .css file like:-

.defaultTxt{font-family : Verdana, Arial, sans-serif ;
font-size:34px;
background-color:Black;}
5)Save it.
6)Now to use these style format in a button control:-
For example-
asp:button id="Button1" cssclass="defaultTxt" runat="server" text="Button"

That is the simplest and easiest way to use style sheets in your code.

Tuesday, September 11, 2007

Installing an Assembly in the Global Assembly Cache.

The steps are follows:-
1)Create a Class Library project in VS.net and name it as GACShow.
2)Generating a public name:
To generate this cryptographic key pair use the SN tool.This tool is located in the \bin subdirectory where the .net framework Software Development Kit(SDK) is installed.
The command-line statement takes the following :
form:sn -k "[DriveLetter]:\[DirectoryToPlaceKey]\[KeyName].snk"
3)Create a directory named GACKey in the C: drive so that you can easily locate and access the key from the command prompt.
Note: For most users, the .NET tools are located in C:\Program Files\Microsoft.NET\FrameworkSDK\Bin. Before you type the following SN command, you may want to copy this similar path on your computer to the .NET bin directory. Type cd from the command prompt, right-click to paste the path, and then press ENTER to quickly change to the directory where the SN Tool is located.
Type the following:
sn -k "C:\GACKey\GACkey.snk"
4)Placing the KeyFile into the Assembly:
A key is generated, but it is not yet associated with the assembly of the project. To create this association, double-click the AssemblyInfo.cs file in Visual Studio .NET Solution Explorer. This file has the list of assembly attributes that are included by default when a project is created in Visual Studio .NET. Modify the AssemblyKeyFile assembly attribute in the code as follows:
[assembly: AssemblyKeyFile("C:\\GACKey\\GACKey.snk")]
5)Compile the project by clicking CTRL+SHIFT+B. You do not have to have any additional code to install a .dll file in the GAC.
6)Placing the Assemby into the GAC:
There are two ways by which you can place the assembly in the GAC-
i)You can install the .dll file by using the Gacutil Tool. If you use the Gacutil Tool, you can use the following command:
c:\>gacutil -I "[DriveLetter]:\[PathToBinDirectoryInVSProject]\projname.dll" It means that place the .dll that you can find in the bin subdirectory of your project.
ii)If you want to drag the file, use Microsoft Windows Explorer. Open two instances of Windows Explorer. In one instance, find the location of the .dll file output for your console project.
In the other instance, find c:\[SystemRoot]\Assembly. Drag your .dll file to the Assembly folder- c:\WINDOWS\Assembly

Monday, September 10, 2007

Sending Email with attachment using ASP.NET & VB.NET.

The following code can be used successfully to send email:-

Dim objEmail As New MailMessage
objEmail.To = strComm 'to whom
objEmail.From = "sumit_daripa@mindtree.com"
objEmail.BodyFormat = MailFormat.Text
objEmail.Subject = "Checking"
objEmail.Body = "Thank you for visiting my website"
objEmail.Body = "Regards-Sumit Daripa"
objEmail.Priority =MailPriority.High
Dim oAttch As MailAttachment = New MailAttachment("c:\Customer.xls")
objEmail.Attachments.Add(oAttch)
SmtpMail.SmtpServer = "indiamail.mindtree.com"
Try
SmtpMail.Send(objEmail)
Response.Write("Your E-mail has been sent sucessfully.")
Catch exc As Exception
Response.Write("Sendfailure: " + exc.ToString())
End Try

Friday, September 7, 2007

Golden Rules For Career Success.

1. Business is made up of ambiguous victories and nebulous defeats. Claim them all as victories.
2. Keep track of what you do; someone is sure to ask You.Make a list of what you are going to do that particular day in the office.
3. Be comfortable around Senior managers, or learn to fake it.
4. Never bring your boss a problem without some solution.
5. You are getting paid to think, not to whine.
6. Long hours don’t mean anything; results count, and not the efforts.
7. Write down ideas; or else they will get lost, like good pens.
8. Always arrive at work 30 minutes before your boss.
9. Help other people network for jobs. You never know when your turn will come.
10. Don’t take days off sick-unless you are.
11. Assume no one will / can keep a secret.
12. Know when you do your best: - morning, night, under pressure, relaxed; schedule and prioritize your work accordingly.
13. Treat everyone who works in the organization with respect and dignity, whether it be the Cleaner or the Managing director. Don’t ever be patronizing.
14. Never appear stressed in front of a client, a customer or your boss. Take a deep breath and ask yourself - In the course of human events, how important is this?
15. If you get the entrepreneurial urge, visit someone who has his own business. It will certainly cure you.
16. Acknowledging someone else’s contribution will always repay you doubly.
17. Career planning is an oxymoron. The most exciting opportunities tend to be unplanned.
18. Always choose to do what you’ll remember ten years from now.
19. The size of your office is not as important as the size of your pay cheque.
20. Understand what finished work looks like and deliver your work only when it is finished.
21.. The person who spends all of his or her time is not hard-working; he or she is boring.
22. Know how to write business letter including “Thank You” notes as well as Proposals.
23. Never confuse a Memo with reality. Most memos from the top are political fantasy.
24. Eliminate guilt. Don’t fiddle with expenses, taxes or benefits, and don’t cheat your colleagues.
25. Reorganizations mean that someone will lose his or her job. Get on the committee that will make the recommendations.
26. Job security does not exist anywhere.
27. Always have an answer to the question “What would I do if I lost my job tomorrow?”
28. Go to the company party.
29. Don’t get drunk at the party.
30. Avoid working at weekends. Work longer during the week if you have to.
31. The most successful people in business are interesting.
32. Sometimes you’ll be on a winning streak and everything will click; take maximum advantage. When the opposite is true, hold steady and wait for it to be out.
33. Never in your life say, “It’s not my job.”
34. Be loyal to your career, your interests and yourself.
35. Understand the skills and abilities that set you apart. Use them whenever you have an opportunity.
36.People remember the end of the project. As they say in boxing, “Always finish stronger than you start.”

Using BreadCrumbs in ASP.Net.

The BreadCrumb is used to maintain the list or keep trail of the pages that one has visited along the way to the present page.
As the breadcrumb is used in the entire project ,so use it as a usercontrol.
Following steps are needed to create a BreadCrumb:-
1)Create a usercontrol and paste the following code in the .ascx.vb page:-
' This class represents a usercontrol helps to implement a breadcrump system
' Usage : Ad the user control to the page where bread crumb system to be implemented
' Add this page tro the DefaultLinks property if it not exiss there
Imports System.Text
Imports System.Collections
Imports System.Collections.Specialized
Public Class BreadCrumb
Inherits System.Web.UI.UserControl

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
Private Sub InitializeComponent()

End Sub
Protected WithEvents lblTrail As System.Web.UI.WebControls.Label

'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

'Variable holding the Link name of the page
Private _tailName As String
'Variable holding the level of the page
Private _level As Short
'The pagecrumb object of the current page
Private _pageCrumb As New BreadCrumb
'We will use a sorted list as we can use the level as key
Private _crumbList As SortedList

'Each page has a level. The page should declare its level
Public Property Level() As Short
' TO DO : We can check for some constraints here
Get
Return _level
End Get
Set(ByVal Value As Short)
_level = Value
End Set
End Property

Public Structure BreadCrumb

Private _level As Short
Private _url As String
Private _linkName As String

'//We are setting all the properties at the time of construction

Public Sub New(ByVal level As Short, ByVal url As String, ByVal linkName As String)

_level = level
_url = url
_linkName = linkName
End Sub

'//We are making all the properties as read-only.
'//We are not expecting it to change once it is set.
Public ReadOnly Property Level() As Short
Get
Return _level
End Get
End Property

Public ReadOnly Property Url() As String
Get
Return _url
End Get
End Property

Public ReadOnly Property LinkName() As String
Get
Return _linkName
End Get
End Property
End Structure


'Each page needs a meaningful name of it. Let them declare it
Public Property TailName() As String
' TO DO : We can check for some constraints here
Get
Return _tailName
End Get
Set(ByVal Value As String)
_tailName = Value
End Set
End Property

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'We are not disabling viewstate
If Not (Page.IsPostBack) Then

'Minimum level is 1
If (_level <= 0) Then
_level = 1
End If

'If no friendly name gives Untitled as default
If (_tailName = "") Then
_tailName = "Untitled"
End If

'Create a Crumb object based on the properties of this page
_pageCrumb = New BreadCrumb(_level, Request.RawUrl, _tailName)

'Check our Crumb is there in the session...if not create and add it...else get it
If Session.Item("HASH_OF_CRUMPS") Is Nothing Then
_crumbList = New SortedList
Session.Add("HASH_OF_CRUMPS", _crumbList)
Else
_crumbList = Session.Item("HASH_OF_CRUMPS")
End If

'Now modify the List of the breadcrumb
ModifyList()
' Put the breadcrumb from the session of sortlist
PutBreadCrumbs()
End If


End Sub

Private Sub ModifyList()
'Remove all Entries from the list which is higher or equal in level
'Because at a level there can be max 1 entry in the list
RemoveLowerLevelCrumbs()
'If level is 1 set the Crumb as home
If _pageCrumb.Level = 1 Then
_crumbList.Clear()
_crumbList.Add(CType(1, Short), New BreadCrumb(1, "/Home.aspx", "Home"))

Else
'If nothing in the list adds the home link first
If _crumbList.Count = 0 Then
_crumbList.Add(CType(1, Short), New BreadCrumb(1, "/Home.aspx", "Home"))
End If
'Now add the present list also no other check is required here as we have cleaned up the
'List at the start of the function
_crumbList.Add(_level, _pageCrumb)
End If
End Sub

'Function will remove all the entries from the list which is higher or equal to the
'present level
Private Sub RemoveLowerLevelCrumbs()

Dim level As Short
Dim removalList As New ArrayList(_crumbList.Count)
For Each level In _crumbList.Keys
If (level >= _level) Then
removalList.Add(level)
End If
Next
'Now remove all keys in the list
For Each level In removalList
_crumbList.Remove(level)
Next
End Sub


Private Sub PutBreadCrumbs()
Dim linkString As New StringBuilder

Dim pageCrumb As New BreadCrumb
Dim index As Integer

For index = 0 To _crumbList.Count - 2
pageCrumb = _crumbList.GetByIndex(index)
linkString.Append(String.Format("{1} ", pageCrumb.Url, pageCrumb.LinkName))
linkString.Append(" > ")
Next index
'Add the tail also
pageCrumb = _crumbList.GetByIndex(index)
linkString.Append(pageCrumb.LinkName)

lblTrail.Text = linkString.ToString()

End Sub
End Class

Now add a label which will display the pages .
So the html part of the usercontrol for the label is:-


Now use the following in the aspx pages which needs the BreadCrumb:-


The level and the tailname changes according to the page that is to be displayed.
So better prepare a sitemap first.

Hope this article will provide a help to you.

Happy Coding,
Sumit Daripa

Wednesday, May 2, 2007

Body Building.

I am devoting this article to my father(who inspired me to body building),Mr.Prakash(My Physical Trainer) and all the other people who helped me ,inspired me and were with me during all these years.

Bodybuilding is the process of developing muscle fibres through the combination of weight training, specific caloric intake, and rest. Someone who engages in this activity is referred to as a bodybuilder.

Early years
The "Early Years" of Bodybuilding are considered to be the period between 1880 and 1930.
Bodybuilding (the art of displaying the muscles of the physical body) did not really exist prior to the late 19th century, when it was promoted by a man from Prussia named Eugen Sandow, who is now generally referred to as "The Father of Modern Bodybuilding". He is credited as being a pioneer of the sport because he allowed an audience to enjoy viewing his physique in "muscle display performances". Although audiences thrilled seeing a well developed physique, those men simply displayed their bodies as part of strength demonstrations or wrestling matches. Sandow had a stage show built around these displays through his manager. He became so successful at it, he later created several businesses around his fame and was among the first to market products branded with his name alone. As he became more popular, he was credited with inventing and selling the first exercise equipment for the masses (machined dumbbells, spring pulleys and tension bands).

The "Golden Age"
The period of around 1940 to 1970 is often referred to as the "Golden Age" of bodybuilding because of changes in the aesthetic for more mass, as well as muscular symmetry and definition, which characterised the "early years". This was due in large part to the advent of World War II, which inspired many young men to be bigger, stronger and more aggressive in their attitudes. This was accomplished by improved training techniques, better nutrition and more effective equipment. Several important publications came into being, as well, and new contests emerged as the popularity of the sport grew.

Areas of Bodybuilding
1 Professional bodybuilding
2 Natural bodybuilding
3 Teenage bodybuilding
4 Female bodybuilding

Contest preparation
The general strategy adopted by most present-day competitive bodybuilders is to make muscle gains for most of the year (known as the "off-season") and approximately 3-4 months from competition attempt to lose body fat (referred to as "cutting"). In doing this some muscle will be lost but the aim is to keep this to a minimum. There are many approaches used but most involve reducing calorie intake and increasing cardio, while monitoring body fat percentage.
In the week leading up to a contest, bodybuilders will begin increasing their water intake so as to upregulate the systems in the body associated with water flushing. They will also increase their sodium intake. At the same time they will decrease their carbohydrate consumption in an attempt to "carb deplete". The goal during this week is to deplete the muscles of glycogen. Two days before the show, sodium intake is reduced by half, and then eliminated completely. The day before the show, water is removed from the diet, and diuretics may be introduced. At the same time carbohydrates are re-introduced into the diet to expand the muscles. This is typically known as "carb-loading." The end result is an ultra-lean bodybuilder with full hard muscles and a dry, vascular appearance.
Prior to performing on stage, bodybuilders will apply various products to their skin to improve their muscle definition - these include fake tan commonly called "pro tan" (to make the skin darker) and various oils (to make the skin shiny). They will also use weights to "pump up" by forcing blood to their muscles to improve size and vascularity, and immediately before competition will often eat sugary foods such as chocolate in order to increase their vascularity.

Strategy
In order to achieve muscle growth , bodybuilders focus in three main lines of action:
1 Resistance weight training
2 Specialised nutrition, incorporating extra protein and supplements where necessary
3 Adequate rest

Resistance weight training
Resistance weight training causes micro-tears to the muscles being trained; this is generally known as microtrauma. These micro-tears in the muscle contribute to the soreness felt after exercise, called delayed onset muscle soreness(DOMS). It is the repair to these micro-trauma that result in muscle growth. Normally, this soreness becomes most apparent a day or two after a workout.

Nutrition
The high levels of muscle growth and repair achieved by bodybuilders require a specialized diet. Generally speaking, bodybuilders require more Calories than the average person of the same height, bodybuilders need a higher amount of calories above their 'maintenance level' in order to increase muscle mass. A sub-maintenance level of food energy is combined with cardiovascular exercise to lose body fat in preparation for a contest. The ratios of food energy from carbohydrates, proteins, and fats vary depending on the goals of the bodybuilder.

Rest
Although muscle stimulation occurs in the gym lifting weights, muscle growth occurs afterward during rest. Without adequate rest and sleep, muscles do not have an opportunity to recover and build. About eight hours of sleep a night is desirable for the bodybuilder to be refreshed, although this varies from person to person. Additionally, many athletes find a daytime nap further increases their body's ability to build muscle. Some bodybuilders take several naps per day, during peak anabolic phases.

The bigger picture.

When I joined MindTree Consulting,I was told from the first day to look into the bigger picture of anything.Looking into the bigger picture means to have a glimpse or rather I should say a perfect view of what is happening where and what are the forces that is letting it to happen.
So I am wrinting a short article on "The Bigger Picture".Hope you will enjoy it...............
Development is imperative, but a short-sighted approach is often the cause of great harm. Sustainable development is that which keeps in mind the long-term effects and benefits of any programme.
Short-sighted development is a disaster. Ravaging natural resources without a long-term vision will destroy the ecology, which is the very source of life. The purpose of development should be to support and sustain life. With the bigger picture in mind, all development plans will factor in the ecology, sociology and psychology. Then the very process of development becomes a conscious endeavour to preserve the planet and its resources. The health of our planet is of utmost importance.
The goal of sustainable development is to build a healthy and happy society. Suppose you have built good infrastructure and have in abundance all the material things you aspire for, but the human psychology is destroyed. In such a scenario, the dream of sustainable development will remain a far-fetched goal. There can be no sustainable development in a society full of stress and violence. A disease-free body, a stress-free mind, a violence-free society and a toxin-free environment are vital elements of sustainable development. If we have to keep opening more and more hospitals and prisons as society develops, it does not augur well. Good infrastructure and prosperity become meaningless if every household has to employ a security guard. Access to more hospitals beds and availability of more prisons are not signs of development.
Sustainable development also means freedom from all types of crimes. There are many types of crime. Destroying the environment is also a crime; cutting down trees is also a crime; dumping toxic waste is also a crime; using non-recyclable materials is also a crime. Environmental pollution is a major crime. Environment is our first body, then come the physical body and the mind, the mental sheath. You have to cater to all the three levels. In reality, man's greed is the greatest pollutant. Greed stops man from sharing with others. Greed also obstructs the preservation of ecology; man is so greedy, he wants to make quick profits and achieve quick results. Whilst being aware of methods to prevent pollution, he may not act upon them because they cost in some manner. This greed not only pollutes the gross, physical environment but also contaminates the subtle atmosphere; it stimulates negative emotions in the subtle mind. These negative emotions impact the minds of all the people around; if one person is angry and agitated, the anger and agitation does not stay limited to that one person but rubs off onto all those whom he comes in contact with. These negative vibrations, once compounded, give rise to unrest in society. Negative feelings of hatred, anger, jealousy are the root cause of all disasters and misery in the world, whether they are economical, political or social in nature. Most of the wars are triggered off by such feelings; and war is always accompanied by waste and natural disasters that take ages to balance out.
In a nutshell what I want to say is that whatever you are doing, you should have a look at the impact and influence it will generate.Or rather you should have a look at the bigger picture.