Monday, March 26, 2012

Data Binding with Variables at run time

on .aspx page: ================

asp:GridView ID="Menu1" runat="server" AutoGenerateColumns="false"
CssClass="DDGridView" RowStyle-CssClass="td" HeaderStyle-CssClass="th" CellPadding="6">
Columns>
asp:TemplateField HeaderText="Table Name" SortExpression="TableName">
ItemTemplate>
asp:DynamicHyperLink ID="HyperLink1" runat="server"><%# Eval("DisplayName") %>
asp:Label ID="Label1" runat="server" Text="Somthein
"><%# "john"+"smith" %><%# 1+2*20 %>
<%# val %>
<%# Request.Browser.Browser %>
asp:Label ID="Label2" runat="server" > <%# gal %>
<%# Request.Browser.Browser %>
/ItemTemplate>
/asp:TemplateField>
/Columns>
/asp:GridView> on .aspx.cs page: ==================
public partial class _Default : System.Web.UI.Page
{
protected int val,gal;
protected void Page_Load(object sender, EventArgs e)
{
var and=Console.ReadLine();
val = 3 +7;
this.DataBind();
gal = 20;
this.DataBind();
System.Collections.IList visibleTables = Global.DefaultModel.VisibleTables;
if (visibleTables.Count == 0)
{
throw new InvalidOperationException("There are no accessible tables. Make sure that at least one data model is registered in Global.asax and scaffolding is enabled or implement custom pages.");
}
Menu1.DataSource = visibleTables;
Menu1.DataBind();
}
}

Friday, March 23, 2012

use of IFormate Provider Interface

Namespace Required : System.Globalization

How to set Calendar and Get INfo from That in .net

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
using System.Collections;

namespace CalanderMethod
{
class Program
{
static void Main(string[] args)
{
List list = new List();
DateTime dt = new DateTime(1900,2,29 ,new JulianCalendar());
HijriCalendar hj = new HijriCalendar();
list.Add(hj.GetYear(dt).ToString());
list.Add(Convert.ToString(hj.GetMonth(dt)));
list.Add(hj.GetMonth (dt).ToString());
list.Add(hj.GetDaysInYear(dt.Year).ToString());
list.Add(hj.GetDayOfYear (dt).ToString());
Console.WriteLine("{0}-this is leap year in Julian Calendar ", dt);
Console.WriteLine("the following information under HIJRI CALANDER");
foreach (var item in list)
{
Console.WriteLine(item);
}
Console.ReadLine();
}
}
}

Shortest Method to find Days Difference in .NET C# 4.0

TimeSpan is another structure defined in the System namespace that represents an elapsed time in units of 100-nanoseconds, which are the same units as the Ticks property of DateTime. Substrcation and Addition of dates followed by the TimeSpan property. DateTime dt1 = Convert.ToDateTime(DateTime.Now.Date.ToString("d")); DateTime dt2 = Convert.ToDateTime(DateTime.Now.Date.AddDays(4).ToString("d")); TimeSpan ts = dt2 - dt1; Console.WriteLine(ts.Days);

Thursday, March 22, 2012

How to set global ERROR Page in ASP.NET

system.web>
customErrors defaultRedirect="testCustomerror.aspx" mode="On">
error statusCode="403" redirect="error403.aspx"/>
error statusCode="427" redirect="error427.aspx"/>
/customErrors>
/system.web>

How do I find the start of the week (both Sunday and Monday) knowing just the current time in C#?

public static class DateTimeExtensions
{
public static DateTime StartOfWeek(this DateTime dt, DayOfWeek startOfWeek)
{
int diff = dt.DayOfWeek - startOfWeek;
if (diff < 0)
{
diff += 7;
}

return dt.AddDays(-1 * diff).Date;
}
}

Which is used thusly:

DateTime dt = DateTime.Now.StartOfWeek(DayOfWeek.Monday);

what is Agile methodology?

Agile methodology: An approach of Software development:
Agile offers new methodological approaches, which works on iterations and always welcome the new changes during the development. Agile approach believe on chunks known as sprint, where both team and client can review their final product in a two weeks time.In this approach customer is involved in development phase, so that they can see real working software in such a small time and they can decide the next steps without loosing their lots of time and money.
Agile is a Methodological approach in respond to the problem faced by traditional software development approaches such as Waterfall or Sequential during the software development.Traditional Model have lots of disadvantage such as poor management of requirement, putting huge effort during the planning phase.

In Agile, project manager can deliver the best product in terms of higher prioritize features.
Agile has few important methods such as
Scrum
XP(Xtreme Programming)
Adaptive Software Development
Dynamic System development Method
However Agile also have some cons like other methodologies, in my view Agile methodology does not have proper documentations, reason being the changes require quick responses, apart from that
before going ahead agile methodology should be understand properly in case of misunderstanding of the agile methodology may create a wrong directions.

Agile methodology having lots of advantages such as
It reduce the number of defects in the final product.
Reduce software cost and time
Due to it's flexible nature agile methodology always welcomes last minute changes
Increase business efficiency.
Each team members become responsible.

Monday, March 19, 2012

How to Solve a problem given by Client or User

these are follwoing Structure which help you Provide a efficient way to Solve Problem:-
1>Design or Make a Problem Understanding Document on the behalf of your understanding (What you understand).
2>Send or confirm it from Client or user that approval .
3>Try to make their UML or Use Case Diagram of the Approval Document.
4>Devide the whole problem in Baby step or small worked.
5>Solve or Complete it untill it will not solved ,dont start any new model..(Remember)
6>Test it first and then go for the New Model
7>Review by someone else
8>Proposed it to your Team Manager.

All Data Type and View in ONE SCREEN

for Default.aspx page:
=======================

and the sqlscript file is:
===========================
/****** Object: Table [dbo].[MovieTable] Script Date: 03/19/2012 12:48:17 ******/
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[MovieTable]') AND type in (N'U'))
DROP TABLE [dbo].[MovieTable]
GO
/****** Object: Table [dbo].[MovieTable] Script Date: 03/19/2012 12:48:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[MovieTable]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[MovieTable](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Title] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Name] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
CONSTRAINT [PK_MovieTable] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
)
END
GO
SET IDENTITY_INSERT [dbo].[MovieTable] ON
INSERT [dbo].[MovieTable] ([Id], [Title], [Name]) VALUES (1, N'English', N'DDLg')
INSERT [dbo].[MovieTable] ([Id], [Title], [Name]) VALUES (2, N'Hindi', N'Sanam')
INSERT [dbo].[MovieTable] ([Id], [Title], [Name]) VALUES (3, N'Urdu', N'HAHK')
INSERT [dbo].[MovieTable] ([Id], [Title], [Name]) VALUES (4, N'Malayalam', N'Lholiy')
SET IDENTITY_INSERT [dbo].[MovieTable] OFF

Friday, March 16, 2012

General learning example on .NET

on .aspx page:
===============

on .aspx.cs page:
==================

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

ltl.Text = System.DateTime.Now.Second.ToString();
if (!IsPostBack)
{
//DropDownList1.Items.Add("AGirijesh");
//DropDownList1.Items.Add("BGirijesh");
//DropDownList1.Items.Add("CGirijesh");
//DropDownList1.Items.Add("DGirijesh");
//DropDownList1.Items.Add("EGirijesh");
ArrayList Items = new ArrayList();
Items.Add("GRIEI");
Items.Add("GRIEI");
Items.Add("GRIEI");
Items.Add("GRIEI");
Trace.Warn("Items");
DropDownList1.DataSource = Items;
DropDownList1.DataBind();

}
spannow.InnerText =DateTime.Now.ToString("T");
//SmtpClient client = new SmtpClient();
//client.Host = "localhost";
//client.Port = 25;
//client.Send("steve@somewhere","bob@gmail.com","Hey this is first app","Lunch at Lemeadian");

}

protected void Button1_Click(object sender , EventArgs e)
{
Button myButton = (Button)sender;

myButton.Text = (Int32.Parse(myButton.Text) + 1).ToString();



}
protected void ImageButton1_Command(object sender, CommandEventArgs e)
{

}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
if(e.X>100 && e.Y>200)
spannow.InnerText +="
"+ e.X.ToString();

spannow.InnerText += "
" + e.Y.ToString();
}
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
Label1.Text = TextBox1.Text;
}
protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
RadioButton rbtCommon = (RadioButton)sender;
if (rbtCommon.Checked == true)
Label1.Text = "i am in " + rbtCommon.ID.ToString();
}
}

Multiple radio button using a single Function but differnt behaviour

on .aspx page :
==================




then write following code on .aspx.cs page :
================================================
protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
RadioButton rbtCommon = (RadioButton)sender;
if (rbtCommon.Checked == true)
Label1.Text = "i am in " + rbtCommon.ID.ToString();
}

Thursday, March 15, 2012

Understand the concept of Click(object sender, ImageClickEventArgs e)

.aspx page:
============
asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Desert.jpg"
onclick="ImageButton1_Click" />
sapn id= "spannow" runat="server">
.aspx.cs page-
==============
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
spannow.InnerText += e.X.ToString();
spannow.InnerText += e.Y.ToString();
}

Multiple Button Click using a single Function

.aspx page:
-=--------
First counter:
div>
asp:Button ID="Button1" runat="server" Text="0" onclick="Button1_Click" />
Second Counter:
asp:Button ID="Button2" onclick="Button1_Click" runat="server" Text="0" />
/div>

.ascx page:
-----------
protected void Button1_Click(object sender , EventArgs e)
{
Button myButton = (Button)sender;
myButton.Text = (Int32.Parse(myButton.Text) + 1).ToString();


}

How to Use

write the follwoing code on Default.aspx pages:
===============================================
body
form id="form1" runat="server"
div
span id="spannow" runat ="server">
/span>
Email sent


div>
form>
body>

and now on Default.aspx.cs page write following code:
====================================================
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
spannow.InnerText =DateTime.Now.ToString("T");
}
}

*Put this < before run it (Use Common Sense)

What is Web Config file?

A web configuration file is a special type of file that you can add to your application to configure your application.
Its an XML file (Case senstive).

if you add your Import namespace in
in web config file then their is no need to import that name space in .aspx page.

its automatically inherit that .

*its page property so think about .aspx page .
for example....



and the Default namespaces are listed under following path:
\windows\microsoft.net\framework\[Ver]\config\web.config

How to Design a simple mail transfer Client

on Default.aspx.cs page ->
=============================

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;


public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SmtpClient client = new SmtpClient();
client.Host = "localhost";
client.Port = 25;
client.Send("steve@somewhere","bob@gmail.com","Hey this is first app","Lunch at Lemeadian");

}
}

on Default.aspx page:
====================
Mail send successfully.

Page Render Block is contained between ...

Wednesday, March 14, 2012

Program to find list of all the Environment Variable in your Machine

//not a single Assembly required.OMG
class Program
{
///
/// 100's of environmental variables and we would like a list of all of them.
///

public static void Main()
{
System.Collections.IDictionary i;
i = System.Environment.GetEnvironmentVariables();
System.Collections.IDictionaryEnumerator d;
d = i.GetEnumerator();
System.Console.WriteLine("Content-Type:text/html\n");
System.Console.WriteLine(i.Count + "\n");
while (d.MoveNext())
{
System.Console.WriteLine("{0}={1} \n", d.Key, d.Value);
}
}
}

what is the purpose of having constructors?

A constructor can be used in cases where every time an object gets created and you want some code to be automatically executed. The code that you want executed must be put in the constructor. That code could be anything, it could check for hard disk space, it could create a file or it could connect to the net and bring a file over. What that code will do shall vary from person to person.


code your way to glory

To make a visual Representation (SNIPPING TOOL)

some helpful tools for designing are :
1.snipping tool
2.Paint
3.Visio
4. Visual studio Daigram object Model Creation .

Monday, March 12, 2012

Use of enableViewState property of label

If you (1) change a property's value in the code-behind, and (2) need to know what value you set in a later postback without recalculating the value, then you need to use ViewState.

for javascript to display message

string script = "alert(' please select Value of SunDay ');";
System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Test", script, true);

Northwindw sql database generator query.


//just open sqlserver 2008 and select new query option and copy your *.sql query code and now click on execute query and now refresh whole database you get something new like
Data base Name : Northwindw
and so many tables inside.

if you have any problem related with Microsoft Sql Server 2008 R2 database let me know.....
:-)

How you Design This write your use case diagram/FRS/UML/ReadMeText

Searver Transfer and Response.Redirect

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Windows.Forms;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Redirect("Default.aspx");
//IIS pipelined mode required.
// Server.TransferRequest("About.aspx");
Server.Transfer("About.aspx");
MessageBox.Show("hey i am after the google.co");
}
}

use of MessageBox.Show()

using System;
using System.Windows.Forms;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
MessageBox.Show("Jai Mata DI");
}
}