Pages

Wednesday, August 18, 2010

Only Decimal values in javascript

Following is the code for only decimal allowed in javascript .

Javascript Code :-



function onlyDemialValues(objEvent, id) {


var iKeyCode;
if (window.event) // IE
{
iKeyCode = objEvent.keyCode;
}
else if (objEvent.which)  // Netscape/Firefox/Opera
{
iKeyCode = objEvent.which;
}
if (iKeyCode >= 48 && iKeyCode <= 57 || iKeyCode == 46 || iKeyCode == 8) {

if (iKeyCode == 46) {
if (document.getElementById(id).value.indexOf(".") != -1) return false;
}

return true;
}
return false;
}

Related Other posts

Friday, July 9, 2010

Table of Content In RDLC

Introduction :
This article show you how you can create Table Of Content In rdlc report . I have written step to fetch page no of the rdlc page .

 Step 1.Go In Report >> Report Properties >> Code >>

Step 2. Write Following code in Code .

Public Function GetValue(PageNo As String) As String
Dim path As String = "Test"
Dim Sb As New System.Text.StringBuilder()
Try
If Not String.IsNullOrEmpty(PageNo.Trim().Split("-"C)(1).ToString()) Then
Dim con As String = "Connection String"
Dim Cn As New System.Data.SqlClient.SqlConnection(con)
Cn.Open()
Dim Cmd As New System.Data.SqlClient.SqlCommand("INSERT INTO DATA(NAME) VALUES('" & PageNo & "')", Cn)
Cmd.ExecuteNonQuery()
Cn.Close()
End If
Return path
Catch Exc As System.Exception
Return Exc.Message
End Try
End Function

Step 3. then add following assembly In references :

System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 

Step 4.Then In header of the report In textbox write

=code.GetValue(Globals!PageNumber & " -  " &  ReportItems!textbox8.Value   )

Step 5. Finally In code behind add Following Code Lines.

ReportViewer1.LocalReport.ExecuteReportInCurrentAppDomain(AppDomain.CurrentDomain.Evidence);
ReportViewer1.LocalReport.ExecuteReportInCurrentAppDomain(System.Reflection.Assembly.GetExecutingAssembly().Evidence);
ReportViewer1.LocalReport.AddTrustedCodeModuleInCurrentAppDomain("System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
ReportViewer1.LocalReport.Refresh();

Page no of Page where textbox8 reside will be insert in database .In these way you can generate Table of Content .Generate One Doc File and merge it with exported Doc File .
 

Related Other posts

Saturday, January 2, 2010

Get column values by comma separated in Sql Server

Get column values by comma separated in Sql Server
Introduction : In this article i will explain you how to get column's values by comma separated in sql server .
It is very easy to get all values of column in one string as separated by comma .

Query for get comma separated value of column in sql server :

Declare @Description varchar(4000)
select @Description = coalesce(@Description + ',' , '') + Name FROM UserTable
print @Description 


Output of query :
seta hamid , bhaumik vora ,vinayak , dave 


Related Other posts

Friday, January 1, 2010

All Sundays between two dates in asp.net C#

Find Sundays between two dates in asp.net C# .
Introduction : In this article i will show you how to get all Sundays between two dates in asp.net c# .
Following is function i have written for getting all Sundays between two dates in c# .It is very just you need to add code and you will able get all Sundays between two dates in c#

protected void Page_Load(object sender, EventArgs e)
{
    DateTime Dt1 = DateTime.Now;
    DateTime Dt2 = DateTime.Now.AddDays(30);
    GetAllSundays(Dt1, Dt2);
}
public void GetAllSundays(DateTime Date1, DateTime Date2)
{
    TimeSpan DateDiff = Date2.Subtract(Date1);
    for (int i = 0; i <= DateDiff.Days; i++)
    {
        if (Date1.Date.AddDays(i).DayOfWeek == DayOfWeek.Sunday)
        {
         Response.Write(Date1.Date.AddDays(i).ToLongDateString() + " " + Date1.Date.AddDays(i).DayOfWeek + "
"); } } }

Related Other posts


Find week number from Date in asp.ne c#

Find the week from the date in asp.net c# :

Introduction : This article describe you how to find week number from date in c# .I have created one function which return you week number from the date in c#  .

C# Code for finding the week number :

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

namespace HamidSite
{
    public partial class Test : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {            
            int WeekNo = GetWeeknumber(DateTime.Now);
        }
        public int GetWeeknumber(DateTime Date)
        {
            try
            {   int iMonth = Date.Month;
                int returnNumber = 0;
                for (int i = 1; i <= 5; i++)
                {
                    if (iMonth == Date.AddDays(-7 * i).Month)
                    { }
                    else
                    {
                        returnNumber = i; break;
                    }
                }
                return returnNumber;  
            }
            catch (Exception Exc) { throw Exc; }
        }
    }
}

Related Other posts