Wednesday 30 January 2013

Telerik RadmaskedTextbox validation experssion for Phone Number that doesn't allow zero at start and not all digits zero in ASP.NET




Validation expression for Phone Number for the mask="(###)###-####"


Here is the Source Code:

<telerik:RadMaskedTextBox ID="RadMaskedTextBox1" runat="server" Label="PHONENUMBER:"Mask="(###)###-####"></telerik:RadMaskedTextBox>

<asp:RequiredFieldValidator Display="Dynamic" ID="MaskedTextBoxRequiredFieldValidator"runat="server" ErrorMessage="Please, enter a phone number." ControlToValidate="RadMaskedTextBox1"></asp:RequiredFieldValidator>

<asp:RegularExpressionValidator Display="Dynamic" ID="MaskedTextBoxRegularExpressionValidator"runat="server" ErrorMessage="Incorrect Format"ControlToValidate="RadMaskedTextBox1"

ValidationExpression="^[\( ][0-9X][1-9][0-9][\) ]?[0-9]{3}[\- ]?[0-9]{4}$">
</asp:RegularExpressionValidator>


Sunday 27 January 2013

Telerik RadmaskedTextbox validation experssion that doesn't allow zero at start and not all digits zero in ASP.NET

Regular Expression that doesn't allow any Zero at start and not all digits will be Zero:-


  1. First take a Radmasked textbox and a RegularExpressionValidation control on the aspx page.
  2. Then design it in your requirements.

Here is the Source Code:

------------------------------------------------------------------------------------------------------------
  <telerik:RadMaskedTextBox ID="RadMaskedTextBox1" Runat="server" MaskType="Standard"        Mask="########" CausesValidation="True">
  </telerik:RadMaskedTextBox>

  <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
     ControlToValidate="RadMaskedTextBox1" ErrorMessage="Input is not valid." 
     ValidationExpression="^(?=.*[1-9])(?:[1-9]\d*\.?|0?\.)\d*$">
 </asp:RegularExpressionValidator>


  • The Blue mark code is the regular Expression.


Friday 25 January 2013

Watermark in Telerik RadDatePicker

How to Give Watermark in Telerik RadDatePicker: Source Code For RadDatePicker:-

    
    
    
    

  • The Yellow mark Code is only to give watermark in RadDatePicker.
  • You can give any type of Watermark According to your requirements.

Tuesday 22 January 2013

Show checkbox Checked item(s) from one Grid view to another Grid view in ASP.NET

How to Show Data from one grid view to another grid view

Here is the Default.aspx(Source Code):

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

namespace LinqToXML
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                SqlConnection con = new SqlConnection("Data Source=DIPTIRANJAN-PC;Initial Catalog=CarProduct;
                                                       User ID=sa;Password=123");
                con.Open();
                SqlCommand cmd = new SqlCommand("SELECT * FROM CAR1", con);
                SqlDataAdapter ad = new SqlDataAdapter(cmd);
                DataSet ds = new DataSet();
                ad.Fill(ds);
                DataTable dt1 = ds.Tables[0];
                ViewState["dt1"] = dt1;
                GridView1.DataSource = dt1;
                GridView1.DataBind();
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            DataTable dt1 = (DataTable)ViewState["dt1"];
            DataTable dt2 = dt1.Clone();
            foreach (GridViewRow row in GridView1.Rows)
            {
                if (((CheckBox)row.FindControl("CheckBox1")).Checked)
                {
                    DataRow row1 = dt2.NewRow();
                    foreach (DataRow row2 in dt1.Rows)
                    {
                        if (row2["Id"].ToString() == GridView1.DataKeys[row.DataItemIndex].Value.ToString())
                        {
                            row1["ID"] = row2["ID"];
                            row1["NAME"] = row2["NAME"];
                            row1["PRICE"] = row2["PRICE"];
                            row1["IMAGE"] = row2["IMAGE"];
                            row1["OILType"] = row2["OILType"];
                            row1["Mileage"] = row2["MIleage"];
                            dt2.Rows.Add(row1);
                        }
                    }
                }
            }
            GridView2.DataSource = dt2;
            GridView2.DataBind();
        }
    }
}
OUTPUT:


Calendar Extender With TextBox in ASP.NET

  • First add a Textbox Control on the Aspx Page.
  • Add image control to display calendar popup.
  • Then go to the source code Add a Calendar Extender and ToolkitScriptManager from the AjaxControlToolkit.

Html Code:






Then run the code:---

OUTPUT

Saturday 12 January 2013

Creating a SQL Server Reporting Services (SSRS) report that contains a Parameter Query

Fibonacci series in c


Fibonacci series in c programming: c program for Fibonacci series without and with recursion. Using the code below you can print as many number of terms of series as desired. Numbers of Fibonacci sequence are known as Fibonacci numbers. First few numbers of series are 0, 1, 1, 2, 3, 5, 8 etc, Except first two terms in sequence every other term is the sum of two previous terms, For example 8 = 3 + 5 (addition of 3, 5). This sequence has many applications in mathematics and Computer Science.

Fibonacci series in c using for loop


/* Fibonacci Series c language */
#include<stdio.h>
 
main()
{
   int n, first = 0, second = 1, next, c;
 
   printf("Enter the number of terms\n");
   scanf("%d",&n);
 
   printf("First %d terms of Fibonacci series are :-\n",n);
 
   for ( c = 0 ; c < n ; c++ )
   {
      if ( c <= 1 )
         next = c;
      else
      {
         next = first + second;
         first = second;
         second = next;
      }
      printf("%d\n",next);
   }
 
   return 0;
}
Output of program:
Fibonacci series program

Fibonacci series program in c using recursion

#include<stdio.h>
 
int Fibonacci(int);
 
main()
{
   int n, i = 0, c;
 
   scanf("%d",&n);
 
   printf("Fibonacci series\n");
 
   for ( c = 1 ; c <= n ; c++ )
   {
      printf("%d\n", Fibonacci(i));
      i++; 
   }
 
   return 0;
}
 
int Fibonacci(int n)
{
   if ( n == 0 )
      return 0;
   else if ( n == 1 )
      return 1;
   else
      return ( Fibonacci(n-1) + Fibonacci(n-2) );
}