Wednesday, 14 November 2012

Ajax AccordianPane control code in asp.net.


Hi Friends, Here I have Explained Ajax AccordianPane control in Asp.Net.

First you have to download Ajax toolkit. You can download Ajax toolkit from Microsoft site. In that go Download section and download AjaxToolsKit for your .Net version means which  visual studio version (Framework)you  use.
When you will use ajax in your page then first register ajax in your page means write the code given code at top of your  design page.
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

AccordianPane.aspx:-
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AccordianPane.aspx.cs" Inherits="Ajax_AccordianPane" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Ajax AccordianPane control example in Asp.net </title>
     <style type="text/css">
.accordionContent {
background-color: #D3DEEF;
border-color: -moz-use-text-color #2F4F4F #2F4F4F;
border-right: 1px dashed #2F4F4F;
border-style: none dashed dashed;
border-width: medium 1px 1px;
padding: 10px 5px 5px;
width:90%;
}
.accordionHeaderSelected {
background-color: #5078B3;
border: 1px solid #2F4F4F;
color: white;
cursor: pointer;
font-family: Arial,Sans-Serif;
font-size: 12px;
font-weight: bold;
margin-top: 5px;
padding: 5px;
width:90%;
}
.accordionHeader {
background-color: #2E4D7B;
border: 1px solid #2F4F4F;
color: white;
cursor: pointer;
font-family: Arial,Sans-Serif;
font-size: 12px;
font-weight: bold;
margin-top: 5px;
padding: 5px;
width:90%;
}
.href
{
color:White;
font-weight:bold;
text-decoration:none;
}
</style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <cc1:Accordion ID="Accordion1" runat="server" SelectedIndex="0" HeaderCssClass="accordionHeader"
              HeaderSelectedCssClass="accordionHeaderSelected" ContentCssClass="accordionContent"
                        FadeTransitions="true" SuppressHeaderPostbacks="true" TransitionDuration="250"
                        FramesPerSecond="40" RequireOpenedPane="false" AutoSize="None"
            Height="538px">
        <Panes>
        <cc1:AccordionPane ID="AccordionPane1" runat="server">
<Header><a href="#" class="href">Login</a></Header>
<Content>
<asp:Panel ID="UserReg" runat="server">
<table>
<tr>
<td></td>
<td align="right" >
</td>

</tr>
<tr>
<td></td>
<td align="right" >
Unique Id:
</td>
<td>
<asp:TextBox ID="txt_login_unique_id" runat="server"></asp:TextBox>
<br />
    <asp:Label ID="lbl_login_unique_id" runat="server" Text="Enter your unique_id." Visible="false" ForeColor="#ff0000"></asp:Label>
</td>
</tr>
<tr>
<td></td>
<td align="right" >
Password:
</td>
<td>
<asp:TextBox ID="txt_login_password" runat="server" TextMode = "Password"></asp:TextBox>
<br />
<asp:Label ID="lbl_login_password" runat="server" Text="Enter your password." Visible="false" ForeColor="#ff0000"></asp:Label>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td align="left" >
<asp:Button ID="btnlogin" runat="server" Text="Login"
        onclick="btnlogin_Click1"/>

</td>
</tr>
</table>
</asp:Panel>
</Content>
</cc1:AccordionPane>
<cc1:AccordionPane ID="AccordionPane2" runat="server">
<Header><a href="#" class="href">New  User Registration</a></Header>
<Content>
<asp:Panel ID="Panel1" runat="server">
<table align="center">
<tr>
<td></td>
<td align="left" colspan="2">
    <asp:Label ID="lbl_reg_password_not_match" runat="server" Text="Password doesn't match." Visible="false" ForeColor="#ff0000"></asp:Label>
    </td>
</tr>
<tr>
<td align="right" colspan="2">
Unique Id:
</td>
<td>
    <asp:TextBox ID="txt_reg_unique_id" runat="server" ></asp:TextBox>
    <br />
    <asp:Label ID="lbl_reg_unique_id" runat="server" Text="Enter your unique_id." Visible="false" ForeColor="#ff0000"></asp:Label>
</td>
</tr>
<tr>
<td align="right" colspan="2">
Password:
</td>
<td>
    <asp:TextBox ID="txt_reg_password" runat="server" TextMode = "Password"></asp:TextBox>
    <br />
        <asp:Label ID="lbl_reg_password" runat="server" Text="Enter your password." Visible="false" ForeColor="#ff0000"></asp:Label>

</td>
</tr>
<tr>
<td align="right" colspan="2">
  Retype Password:
</td>
<td>
<asp:TextBox ID="txt_reg_retype_password" runat="server" TextMode = "Password"></asp:TextBox>
<br />
        <asp:Label ID="lbl_retype_password" runat="server" Text="Enter your retype password." Visible="false" ForeColor="#ff0000"></asp:Label>
</td>
</tr>
<tr>
<td align="right" colspan="2">
Security Question:
</td>
<td>
    <asp:DropDownList ID="ddl_security_question" runat="server">
    </asp:DropDownList>
    <br />
        <asp:Label ID="lbl_security_question" runat="server" Text="Select your question." Visible="false" ForeColor="#ff0000"></asp:Label>
</td>
</tr>
<tr>
<td align="right" colspan="2" >
Answer :
</td>
<td>
<asp:TextBox ID="txt_reg_answer" runat="server"></asp:TextBox>
<br />
        <asp:Label ID="lbl_reg_answer" runat="server" Text="Enter your password." Visible="false" ForeColor="#ff0000"></asp:Label>
</td>
</tr>
<tr>
<td></td>

<td align="left" colspan="2"  >
   
    <asp:Button ID="btn_register" runat="server" Text="Register"
        onclick="btn_register_Click" />
</td>

</tr>
</table>
</asp:Panel>
</Content>
</cc1:AccordionPane>
        </Panes>
        </cc1:Accordion>
  
    </div>
    </form>
</body>
</html>
AccordianPane.aspx.cs:-

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

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

    }
    protected void btnlogin_Click1(object sender, EventArgs e)
    {
        // write your login button code here.
    }
    protected void btn_register_Click(object sender, EventArgs e)
    {
        // write your registration button code here.
    }
}
Hope you will enjoy from this post. If any problem regarding this post you can contact me at sushilct86@gmail.com.

How to add AjaxToolKit Control in you Visual studio.


First download AjaxToolKit Control from website. Do not need to go here and there , just go to Microsoft Website and from Download section download ajaxtoolkit control  as per your requirement(means which framework you use.) because it absolutely free.
Open  visual studio -> Open any Design page -> Go to ToolBox -> click on AjaxExtension -> Right click on AjaxExtension -> select  choose Items -> wait for a moment -> This will a window -> click on Browse button  -> select your AjaxToolKit.dll file -> click ok ->  It wiil add ajax control in your ToolBox within an AjaxExtension.
Hope you will enjoy from this post. No need to go to anywhere  Just Follow my blog ….and Spread it in your friends…

Tuesday, 13 November 2012

How to show data in Gridview using SqlDataSource in Asp.Net .


Hi Friend’s , In this post I have explained  how to use SqlDataSource in GridView to show the Table data.

Introduction:

SqlDataSource connects to data sources, retrieve data from them and then makes this data available for other control to bind to, without the headache of writing code.
Below I have explained step by step with Figure.
First open a new web site in visual studio -> Give  name to it -> click ok.
In design Page drag and drop a GridView Control on it.Click on GridView control , you will see a box at right side on top -> click on this box -> choose new data source . See the figure..

After this choose Sql Datasource.

After it will open Configure data source window. Select your connection from the drop down list, if connection is not available then click on new connection option. To countinue ,click on the next button. In the next screen , pass the sql query to the ‘Configure the select statement ‘ screen as shown in the figure below.

Finally click on Finish Button. This will automatically add the sqlDataSuorce control to the web page.
GridView.aspx:-
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GridView.aspx.cs" Inherits="GridView" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
            DataSourceID="SqlDataSource1">
            <Columns>
                <asp:BoundField DataField="userName" HeaderText="userName"
                    SortExpression="userName" />
                <asp:BoundField DataField="password" HeaderText="password"
                    SortExpression="password" />
                <asp:BoundField DataField="firstName" HeaderText="firstName"
                    SortExpression="firstName" />
                <asp:BoundField DataField="LastName" HeaderText="LastName"
                    SortExpression="LastName" />
                <asp:BoundField DataField="email" HeaderText="email" SortExpression="email" />
                <asp:BoundField DataField="phoneno" HeaderText="phoneno"
                    SortExpression="phoneno" />
                <asp:BoundField DataField="location" HeaderText="location"
                    SortExpression="location" />
                <asp:BoundField DataField="createdBy" HeaderText="createdBy"
                    SortExpression="createdBy" />
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server"
            ConnectionString="<%$ ConnectionStrings:modiConnectionString %>"
            SelectCommand="SELECT [userName], [password], [firstName], [LastName], [email], [phoneno], [location], [createdBy] FROM [m_registration]">
        </asp:SqlDataSource>
   
    </div>
    </form>
</body>
</html>


Press F5 button. If You like this blog ,please spread this blog to all your friends.

Monday, 12 November 2012

.NET validation in asp.net.


Hi Friend’s , Here I have explained validation in .NET.

Introduction:

Validation controls are hidden controls which are used to validate the data, provided by the user at the client end. As we know that sending a request to the server, it takes lot of time to respond. So it becomes very costly to send all the data entered by the user at the client side, to the server side for the validation. Validation controls work at the client side end only if the browser support JavaScript and some DHTML and can check the date before it sending it to the server.
You can assign more the one validation control to the same data-entry- control, if you want to check multiple conditions at the same time.
There are six type of validation in .NET  which is defined as below:-
1.) Required Field Validator:
This is the simplest control , which is used to ensure that user  has enter the data in data-control or not. Means if user has left blank the field then it will show the error on the page.
You  can add this control by simple drag and drop from the ToolBox control  and simply double click on this control.
When you add RequiredFieldValidation  control on your page , it add the following code on your web page:-
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>

Example:
Validation.aspx:

<asp:TextBox ID="TextBox1" runat="server" style="z-index"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="This Field cann't be empty."></asp:RequiredFieldValidator>

<asp:Button ID="Button1" runat="server" Text="Submit" />

Run this code . When user click on submit button without filling the field then it will show the error message like ” This field cnn’t be empty.” (You can give any type of error message according to you field.)
2.) RangeValidator Control:
This control is used  to test  if the data entered by the user in a data-entry-control is inside a specified range of values.
Add a RangeValidation Control on your web page by simple drop and drag or doule click on the data-control .
When you add RangeValidationControl  on your page , it add the following code on your web page:-
<asp:RangeValidator ID="RangeValidator1" runat="server" ErrorMessage="RangeValidator"></asp:RangeValidator>

Example:
Validation.aspx:
<asp:TextBox ID="TextBox2" runat="server" style="z-index"></asp:TextBox>
<asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="TextBox2" MinimumValue="18" MaximumValue="60" ErrorMessage="Age should be in the range of 18 to 60."></asp:RangeValidator>
<asp:Button ID="Button1" runat="server" Text="Submit" />

Run this code . When user click on submit button without filling the field then it will show the error message like ” Age should be in the range of 18 to 60.”
3.)RegularExpressionValidator :
This control is used  to test if the data entered by user in a data-entry control matches a pattern defined by regular expression. A regular expression is a string that match a set of string  according to certain syntax  rules.
For example RegularExpression for email  is : \w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
When you add RegularExpressionValidator on your page , it add the following code on your web page:-
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="RegularExpressionValidator"></asp:RegularExpressionValidator>

For example
Validation.aspx:
<asp:TextBox ID="TextBox3" runat="server" style="z-index"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
            ErrorMessage="please enter your mail like sushilct26@gmail.com"
            ControlToValidate="TextBox3"
            ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
        <asp:Button ID="Button1" runat="server" Text="Submit" />

Run this code . When user click on submit button without filling the field then it will show the error message like ” please enter your mail like sushilct26@gmail.com.”
4.)CompareValidationControl:
This control is used for compare the two data-entry control field .i.e  for password and compare password when user sign up first time .
Add a CompareValidationControl Control on your web page by simple drop and drag or doule click on the data-control .
When you add CompareValidationControl on your page , it add the following code on your web page:-
<asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="CompareValidator"></asp:CompareValidator>

Example:
Validation.aspx:
<asp:TextBox ID="TextBox4" runat="server" style="z-index"></asp:TextBox>
<asp:TextBox ID="TextBox5" runat="server" style="z-index"></asp:TextBox>
<asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="TextBox4" ControlToCompare="TextBox5" ErrorMessage="Type the same password as entered above."></asp:CompareValidator>
        <asp:Button ID="Button1" runat="server" Text="Submit" />

Run this code . When user click on submit button without filling the field then it will show the error message like Type the same password as entered above.”
5.)CustomValidatorControl:
This validation control is  used  to test the data-entry control  data in your own ways. But this validation control has some restriction. You can use this control only for range checking  and comparisons. For example if you want to check whether a number is even or odd then it is not possible for existing validation control. For this type of problem we use CustomeValidation control.
Add a CompareValidationControl Control on your web page by simple drop and drag or doule click on the data-control .
When you add CompareValidationControl on your page , it add the following code on your web page:-
<asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="CustomValidator"></asp:CustomValidator>

Example:
Validation.aspx:
<asp:TextBox ID="TextBox4" runat="server" style="z-index"></asp:TextBox>
<asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="TextBox6" ClientValidationFunction="validation" ErrorMessage="Enter the correct password."></asp:CustomValidator>
        <asp:Button ID="Button1" runat="server" Text="Submit" />
Run this code . When user click on submit button without filling the field then it will show the error message like Enter the correct password.”(This message will pop up when you enter any thing instead  of New York.)
6.) ValidationSummaryControl:
This control is used to display  summary of all error message from all validation control on a web page.
Add a ValidationSummaryControl Control on your web page by simple drop and drag or doule click on the data-control .
When you add ValidationSummaryControl on your page , it add the following code on your web page:-
<asp:ValidationSummary ID="ValidationSummary1" runat="server" />
Example:
Validation.aspx:
<asp:TextBox ID="TextBox1" runat="server" style="z-index"></asp:TextBox>
        <asp:TextBox ID="TextBox2" runat="server" style="z-index"></asp:TextBox>
        <asp:TextBox ID="TextBox3" runat="server" style="z-index"></asp:TextBox>
        <asp:TextBox ID="TextBox4" runat="server" style="z-index"></asp:TextBox>
        <asp:TextBox ID="TextBox5" runat="server" style="z-index"></asp:TextBox>
        <asp:TextBox ID="TextBox6" runat="server" style="z-index"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="This Field cann't be empty."></asp:RequiredFieldValidator>
        <asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="TextBox2" MinimumValue="18" MaximumValue="60" ErrorMessage="Age should be in the range of 18 to 60."></asp:RangeValidator>
        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
            ErrorMessage="please enter your mail like sushilct26@gmail.com"
            ControlToValidate="TextBox3"
            ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
        <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="TextBox4" ControlToCompare="TextBox5" ErrorMessage="Type the same password as entered above."></asp:CompareValidator>
        <asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="TextBox6" ClientValidationFunction="validation" ErrorMessage="Enter the correct password."></asp:CustomValidator>
        <asp:ValidationSummary ID="ValidationSummary1" runat="server" />
        <asp:Button ID="Button1" runat="server" Text="Submit" />

Run this code . When user click on submit button without filling the field then it will show the error message  from all validation.
Donn't forget to comment this post.

Monday, 5 November 2012

How to get free recharge your mobile from internet.

 Hi Friends , here I have explained about how to get free recharge your mobile form internet.

Go to onlinegamesnow.com and sign up there and play the game and when u rich at 10 ONG poit then you will able to recharge your mobile free. Or Click Here
Hope you will enjoy. Feel free to give a comment.

In next post I will bring a new thing.................. To be countinued.

JavaScript Validation code in asp.net .



Here I have  write some validation code in asp.net for  required field , range validator, email validator ,phone validator etc.
Below all codes are given :
Write this code in header :


<script>
    function val() {
        c = /^[a-zA-Z]*$/;
        if (document.getElementById("TextBox1").value.match(c) == null) {
            alert("please enter your uname and in proper formate.");
            return false;
        }
        if (document.getElementById("TextBox2").value == "") {
            alert("please enter your first name.");
            return false;
        }

        if (document.getElementById("TextBox3").value == "") {
            alert("please enter your last name.");
            return false;
        }

        if (document.getElementById("TextBox4").value == "") {
            alert("please inter your email id.");
            return false;
        }
        e = /^[a-z A-Z 0-9_\.\-]\+@(([a-z A-Z 0-9\-])+\.)+([a-z A-Z 0-9]{2,4})+$/;
        if (document.getElementById("TextBox4").value.match(e) == null) {
            alert("please inter your email id in proper formate.");
            return false;
        }
        if (document.getElementById("TextBox5").value == "") {
            alert("please enter your password");
            return false;
        }

        if (document.getElementById("TextBox6").value == "") {

            alert("please enter your cpass");
            return false;
        }
        if (document.getElementById("TextBox7").value == "") {
            alert("please enter your mobile no.");
            return false;
        }
        p = document.getElementById("TextBox7").value;
        if (isNaN(p)) {
            alert("please enter your mobile no in digit.");

            return false;
        }
        if (document.getElementById("TextBox7").value.length < 10) {
            alert("mobile no must be ten digit no.");
            return false;
        }
        if (document.getElementById("TextBox7").value.length > 10) {
            alert("mobile no must be ten digit no.");
            return false;
        }
        if (document.getElementById("TextBox8").value == "") {
            alert("please enter your date of birth.");
            return false;
        }
        if (document.getElementById("RadioButtonList1").value == "") {
            alert("please enter your cpass");
            return false;
        }
    }
</script>

After this you can call this function  on control where you want .
For example:
<asp:TextBox ID="TextBox1" runat="server" onkeyup="reurn val();"></asp:TextBox>

If any query regarding this post feel free to ask or send a mail.


Friday, 2 November 2012

How to use stored procedure in Linq in asp.net using c#.

In the previous post I had explained "How to show table data in gridview using Linq in asp.Net".
In this post ,I have explained How to use stored procedure in linq in asp.net using c#.
Here I have explained step by step.

First create a table in sql server.
Then after create a procedure for this table.
Now open visual studio -> create new web site -> Give a name -> click ok.
Right click on project application -> add new item ->select linq to sql -> give  a name(for example linqToSqlUsingStoredProcedure.dbml).
After click ok button, open a new window -> in new see the right side panel -> drag and drop the procedure from server explorer. Save the .dbml file.
                                                                                                                               
  Now come on design page where you drag and drop a gridview .

Default.aspx


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="LinqusingStoredProcedure.aspx.cs" Inherits="LinqusingStoredProcedure" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:GridView ID="GridView1" runat="server">
    </asp:GridView>
    </div>
   
    </form>
</body>
</html>

Default.aspx.cs:

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

public partial class LinqusingStoredProcedure : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        linqtosqlusingstoredprocedureDataContext ct = new linqtosqlusingstoredprocedureDataContext();// here linqtosqlusingstoredprocedureDataContext is .dbml file name
        var myreg = ct.registration();
        GridView1.DataSource = myreg;
        GridView1.DataBind();
    }
}

Run the project. Hope you will enjoy.If any query regarding this post write a comment or send a mail at sushilct86@gmail.com

Thursday, 1 November 2012

How to hide some important secret file in image?

Hi Friend's , Here I have explained " How to hide secret file in image."
You all know there a lock folder software for locking folder with key. But it is not secret from your friend that means when your friend see folder lock then he will definitely to you  to open the folder. At that time you have to open the file for your friend.
So that why I have explained here step by step how to hide secret file in image.
Here hiding means hide the file (any type of file or document) in image. If anyone try to open this image , simply it will open like image.

Step1. Make a folder with any name on desktop. Here I have given a name sushil.
Step2. Open the folder which you make. Put the File or document in this folder.
Step3. Right click on folder -> Add to archive
Step4. Select rar or zip  from newly open widow -> click ok // Remember extension of file ,it needs to add in cmd.
Step5. Now you get the respective rar or zip file with same name as your desktop folder.
Step6. Copy any image on desktop here i  copy image sun.jpg
Step7. Open Command Prompt
Step8. type  in cmd "copy /b sun.jpg+ sushil.zip hello.jpg" (without quotes.)
Step9. After pressing enter , it will show a message 1 file is copied.

when you double click on image this will open just like image.
If you want to  see your data just open this image then right click on image -> open with rar or zip .

This is working. Hope you will enjoy a lot. Don't forget to comment for this post.