Tuesday, October 17, 2006

Thanks for visiting my blog

Hello Visitors,

Thanks For visiting my blogs. I got 250 visitors in just one month. Thanks for giving time to my blogs. I promise you that i will keep posting new technology blogs. I will post all the new things related to ASP.NET 2.0,C#.NET,VB.NET related things.

I want your suggestions so please put your comments and do visit my guestbooks.

Regards,

Jalpesh
Share:
Saturday, September 30, 2006

Page Counter in ASP 3.0

Lots of guys had done programming for page counter for a site.

I found a interesting example on IIS 5.1 documentation. It is

very easy and very cool. You can developer your page counter

with 2 or 3 line of code in asp 3.0.

Following are the code:


<%

Set MyPageCounter = Server.CreateObject("MSWC.PageCounter")

HitMe = MyPageCounter.Hits

Response.Write("Total Count:" & HitMe)

%>


Thats it your counter is ready.


Happy Programming...

Share:
Saturday, August 26, 2006

code for date picker combobox control in asp.net:

ASP.NET provides calendar control to select date
but some time it not feasible due to the size of
it. It takes more spaces. So we are required
to create a new web control which is used less
space and also provides date selection mechanism
here are the code for that control in C#

HTML CODE:
================================================
<asp:dropdownlist id="cmbDay" AutoPostBack="True"

runat="server"></asp:dropdownlist>



<asp:dropdownlist id="cmbMonth" AutoPostBack="True"

runat="server"></asp:dropdownlist>



<asp:dropdownlist id="cmbYear" AutoPostBack="True"

runat="server"></asp:dropdownlist>
Server Side Code in C#:
====================================================
namespace Jalpesh.Control
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Microsoft.VisualBasic;

public class DatePicker : System.Web.UI.UserControl
{
public System.Web.UI.WebControls.DropDownList cmbDay;
public System.Web.UI.WebControls.DropDownList cmbMonth;
public System.Web.UI.WebControls.DropDownList cmbYear;
private static string _SelectedDate;
public string _SetDate;
public static string SelectedDate
{
get
{
return _SelectedDate;
}
set
{
_SelectedDate=value;

}
}
public string SetDate
{
get
{
return _SetDate;
}
set
{
cmbYear.Items.FindByValue(cmbYear.SelectedValue).Selected=false;
cmbYear.Items.FindByValue(System.Convert.ToDateTime(value).
Year.ToString()).Selected=true;
cmbMonth.Items.FindByValue(cmbMonth.SelectedValue).Selected=false;
cmbMonth.Items.FindByValue(System.Convert.ToDateTime(value).
Month.ToString() ).Selected=true;
cmbDay.Items.FindByValue(cmbDay.SelectedValue).Selected=false;
cmbDay.Items.FindByValue(System.Convert.ToDateTime(value).Day.
ToString() ).Selected=true;
SelectedDate= cmbMonth.SelectedValue.ToString() + "/" +
cmbDay.SelectedValue.ToString() + "/" +
cmbYear.SelectedValue.ToString();

}
}

private void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
FillYear();
FillMonth();
FillDay(int.Parse(cmbMonth.SelectedValue),
int.Parse(cmbYear.SelectedValue));
SelectedDate= cmbMonth.SelectedValue.ToString() + "/"
+cmbDay.SelectedValue.ToString() + "/" + cmbYear.SelectedValue.ToString();
}
}
public void FillDay(int Month,int Year)
{
cmbDay.Items.Clear();
int a;
a=Year%4;
int count;
count=0;
switch(Month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
count=31;
break;
case 4:
case 6:
case 9:
case 11:
count=30;
break;
case 2:
if(a==0)
{
count=29;
}
else
{
count=28;
}
break;
}

for (int i=1;i<=count;i++) { ListItem lstItem=new ListItem(i.ToString(),i.ToString()); if (i==(int.Parse(System.DateTime.Today.Day.ToString() ))) { lstItem.Selected=true; } cmbDay.Items.Add(lstItem); } } public void FillYear() { int i; cmbYear.Items.Clear(); for (i=1900;i<=3000;i++) { ListItem lstItem=new ListItem(i.ToString(),i.ToString()); if (i==(int.Parse(System.DateTime.Today.Year.ToString() ))) { lstItem.Selected=true; } cmbYear.Items.Add(lstItem); lstItem=null; } } public void FillMonth() { int i; cmbMonth.Items.Clear(); for(i=1;i<=12;i++) { ListItem lstItem=new ListItem(GetMonthName(i,false),i.ToString()); if (i==(int.Parse(System.DateTime.Today.Month.ToString() ))) { lstItem.Selected=true; } cmbMonth.Items.Add(lstItem); lstItem=null; } } static string GetMonthName(int monthNum, bool abbreviate) { if(monthNum <> 12)
throw new ArgumentOutOfRangeException("monthNum");
DateTime date = new DateTime(1,monthNum,1);
if(abbreviate)
return date.ToString("MMM");
else
return date.ToString("MMMM");
}



#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);
}


private void InitializeComponent()
{
cmbDay.SelectedIndexChanged += new System.EventHandler(this.cmbDay_SelectedIndexChanged);
cmbMonth.SelectedIndexChanged += new System.EventHandler(this.cmbMonth_SelectedIndexChanged);
cmbYear.SelectedIndexChanged += new System.EventHandler(this.cmbYear_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void cmbYear_SelectedIndexChanged(object sender, System.EventArgs e)
{
FillDay(int.Parse(cmbMonth.SelectedValue),int.Parse(cmbYear.SelectedValue));
SelectedDate= cmbMonth.SelectedValue.ToString() + "/" +cmbDay.SelectedValue.ToString() + "/" + cmbYear.SelectedValue.ToString();
}

private void cmbMonth_SelectedIndexChanged(object sender, System.EventArgs e)
{
FillDay(int.Parse(cmbMonth.SelectedValue),int.Parse(cmbYear.SelectedValue));
SelectedDate= cmbMonth.SelectedValue.ToString() + "/" +cmbDay.SelectedValue.ToString() + "/" + cmbYear.SelectedValue.ToString();
}

private void cmbDay_SelectedIndexChanged(object sender, System.EventArgs e)
{
SelectedDate= cmbMonth.SelectedValue.ToString() + "/" +cmbDay.SelectedValue.ToString() + "/" + cmbYear.SelectedValue.ToString();
}

}
}
Share:
Thursday, August 24, 2006

Thank You For Visiting My Blog

Thank You Very Much for visiting my blog,

There are 155 visitors in last month who visit my blog. It is such
a over whelming experience that you work is recognized in such big way.

I want your valuable comments on my post to make it better. So please put
your comments for the post directly.

You can also put your valuable comments in my guest book:

here are the links:


Post Your Comments
Share:

Sql Server Escape Sequence

Some times we are required to put '(Quotation Mark) in our sql stored procedure query.But '(Quotation Mark) will use for operation in sql server stored procedure. You can use escape sequence here.
for example you want to put 'jalpesh' in stored procedure then you should give
print '''jalpesh'''
here first two quota ion mark counted as escape sequence and then the third ' are counted as character.
Share:

Support this blog-Buy me a coffee

Buy me a coffeeBuy me a coffee
Search This Blog
Subscribe to my blog

  

My Mvp Profile
Follow us on facebook
Blog Archive
Total Pageviews