Showing posts with label Csharp. Show all posts
Showing posts with label Csharp. Show all posts

Thursday, April 18

How to Bind State by Selecting Country DropDownList using WebMethod in Asp.net

Introduction:-
                 In this article I have explained  how to bind a dropdownlist using Ajax.
Description:-
               Some developers binding the dropdownlist directly in pageload.which will give low performance to your site.Now a days every user wants to avoid unnecessary postbacks during any events.Lets take a common example that  I want to bind a state list according to the country selection. I can do it in code behind selectedindexchange event,but it will result performance issue as discussed previously,so I will prefer to use ajax here.

How to Save Image in Different Size in Asp.net

Introduction:-
                     This article explains how to create a image with different size in asp.net.
Description:-
                     In my previous post How to Upload and Save Image Without any Postback by User in Asp.net ,I have explained on image file validation check in javascript as well as instantly reading the image after selecting from dialog box.Here I am going to explain how you can store that same image in different sizes.
   
                   You have to specify some unit to store image in different sizes.As I have explained before you have to take one image upload control and one image viewer control.There is so many different approach is there to do this work but I am providing code which is very simple to implement as well as light weight than other approaches.

Encription and Decription of Password In Asp.net C#

Introduction:-
                     I have explained here how to encrypt and decrypt a string value.
 
Description:-
                     It is became mandatory for all developer to store their password in encrypted because of security reason.And it is the best practice for a developer.If someone wants to store something secretly ,then we should go for it .To store a password in encrypt manner ,it will create  headache  for  hackers to find your password easily.
                                If you will store some string value in encrypted way,then it is quite obvious for an developer to decrypt that string for further use in that application.For an example if some store the encrypted  password in database,But while they want to retrieve their password it won't come the exact one rather encrypted one.Hence we will decrypt that string in that scenario.  

Send sms to mobile in asp.net using fullonsms free api

Introduction:-
                   How to send free sms to mobile using fullonsms api in asp.net.

Description:-

 
                It is very easy to send a sms by using fullonsms in asp.net.Before that you should have an account their.If you do not have an account then follow the steps to create one.
First create one account in http://fullonsms.com/login.php and in source code update the username and password accordingly.
After you have created an account,you can use that registered number to send sms to other numbers in asp.net.
There is a drawbacks here ,First it is useless for those numbers who has not registered in fullonsms.That means both the sender  and the receiver  should have an account on fullonsms.
If the receiver doesn’t have an account on fullonsms ,then you can’t able to send sms to that number unless and until that user is not going to register their number on fullonsms.
For me you should go for a bulk sms package service rather for fullonsms and way2sms free api.
If still you want to use free fullonsms service then follow the following procedure.

Send free sms using asp.net source code

Introduction:-
                     Here I have explained how to send sms using asp.net.
Description:-
                     In my previous article I have explained the same functionality in different approach.Also I have explained some guidelines of using this functionality in Send sms to mobile in asp.net using fullonsms free api.
As I have discussed before you should choose sms gateways package instead of free gateway like fullonsms and way2sms.
Way2sms has stopped their free services for asp.net. In the meantime fullonsms is only those user where the sender and receiver both are a registered user of fullonsms.

Saturday, March 23

How to retrieve data using linq query in DataTable

Introduction:-
                     Here I have explained How to retrieve data using linq query stored in DataTable in asp.net.
Description:-
In this Article I will explain how to store data into datatable using linq query in asp.net.I have used here data context class and by creating the object of that class we can get the tables present inside that object.

Thursday, November 22

Image cropping using jquery

Introduction:-
                     Here I have explained How to crop image with jquery  and asp.net.
Description:-
In this article I will explain how you can crop your selected image using jQuery and asp.net.
You have follow the below steps to get the result.It will be better if you will copy and paste the code I have written below to see the output.

Wednesday, November 7

How to Lock a Form or How to set a form as Not Movable as well as Fixed Size


Introduction:-

                  Here I have explained how to Lock windows form in windows application.

Description:-

                 In my previous article I have explained Generate Barcode in windows application .Here I will explain how a form can’t be movable. We can lock a windows form to set as fixed position where a user can not able to resize that form as well as they can’t able to change the position of that form.

Sometimes it will be a mandatory when you want to open window inside a master form with fixed size. Then we definitely go for this approach.

It is very simple to fix a window form by some few lines of code in your windows application. For this write a override method for WndProc.
 

Monday, October 29

How to Break the Text in a Gridview


Introduction:-

                  Here I have explained how to break text in gridview.

Description:-


Here I will explain how to break the text in gridview in asp.net.When we have fixed the gridview width and height,then if one of the column text exceed the width ,it will display as unprofessional ,to avoid this we have to break that long text.

I will explain you with a suitable example where you can find the gridview with exact text as well as breaking text.


First I am going to show you without breaking text. For this I have taken one gridview and bind that gridview from database as shown below.

Thursday, October 18

Binding Second Gridview By selecting First Gridview Record


Introduction:-

                  Here I have explained how to bind a child gridview by selecting a row of parent gridview in asp.net.

Description:-

                  In my previous article I have explained Different ways to bind data in a textBox from gridview cells by click on select button using both row command and selected index changed event , How to get row number from gridview on textbox change event using javascript without page refreshing , How to show a pop up with gridview row data using string builder as well as how to change gridview row color dynamically? , Gridview row editing, updating, deleting and row command events , Upload a excel file and display it in a gridview as well as display this excel sheet from a starting row to ending row, Adding dynamic rows in asp.net gridview control with textboxes and with delete functionality , Without data showing gridview with empty textbox to submit data into database , Using asp.net gridview EmptyDataTemplate and FooterTemplate add record to database , how to insert images into database and how to retrieve and bind images to gridview using asp.net (or)save and retrieve images from database using asp.net .

                In this article I have taken two gridview control where I am displaying the selected row data of first gridview in second gridview.

Saturday, October 13

How to bind second Gridview with respect to first GridView

Introduction:-

                  Here I have explained RowEditing,RowUpdating,RowDeleting and RowCommand Events of gridview in asp.net.

Description:-


In previous post I have explained how to bind gridview by selecting a row from another gridview where data retrieves from database but in this example I will explain the same post with different approach without using database.
Here I have created two classes and using list collection binding two gridview.First it wil bind one gridview and by choosing any row data it will bind the another gridview having same record.

Here I am going to provide an example with source code, take a look. 

Generate Barcode in windows application


Introduction:-

                  Here I have explained how to generate Barcode and Qrcode in windows application.

Description:-

                  In my previous article I have explained How to lock a form or how to set a form as notmovable as well as fixed size .
 
Here I will explain how to generate barcode as well as qrcode using C#.I have provided all the procedures here to generate barcode and qrcode.

Follow the following process

First download QRCODE GENERATOR LIBRARY from onbarcode.com and then add reference to OnBarcode.Barcode.Winforms.dll to your windows application.

Now I am going to provide all code, what I have written to generate Barcode as well as Qrcode.


Tuesday, October 2

How to return List of Array


Introduction:-

                     Here I have explained how to return array list in webmethod.

Description:-


Here I am going to explain how return array list. If you are using Ajax method to bind a
dropdownlist or any grid controls, then you have to return some value from webmethod.  
Where as you must return a list value to your ajax success function to bind that control.

For this I am using here array list as return value.

Tuesday, September 4

How to Show a pop up with Grid View row data using String Builder ? and How to change Gridview Row Color Dynamically ?


Introduction:-

                     Here I have explained how to show gridview row data in pop up  using string builder as well as I have explained how to change gridview row color dynamically.

Description:-

                  In this article I will explain how to show a pop up view like modal pop up using string builder. For this I have taken one gridview control and checkbox inside that gridview. Here I have also explained how to select all checkboxes at a time and also uncheck.


I will explain it more briefly with my source code and table design structure.


Most of the developer uses modal popup control to show records,but I am providing one new procedures to show record in the same manner.


As I have discussed, here I am going to explain, how to show gridview row data in pop up using String Builder.

I have used here one aspx page with a gridview control. Also I have used two images as CloseTab2.jpg and SearchButton.gif in my images folder and .js script in Scripts folder and one sql server database ShibashishDatabase.mdf in App_Data folder as shown Below.

Thursday, August 9

Download Source Code AutoComplete TextBox Using Webservice Application

I am shibashish mohanty going to show you a simple Auto complete Application using web services.

Dopwnload Source Code From My Code Project Article

My source Code:-


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TextBoxAutoComplete.aspx.cs" Inherits="Test.LINQInsert" %>

<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>

<!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>
    <script type="text/javascript">
        function setCompanyMasterID(source, eventargs) {
            document.getElementById("Label2.ClientID").value =
                                         eventargs.get_value();
            document.getElementById("Label2.ClientID").value =
       document.getElementById("TextBox1.ClientID").value;
        }
</script>
    </head>
<body>
  
    <form id="form1" runat="server">
<asp:ScriptManager runat="server"></asp:ScriptManager>
   
   
    <table >
        <tr>
            <td  >
                ID</td>
            <td>
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
   
   
            </td>
        </tr>
        <tr>
            <td>
                Name</td>
            <td>
                <asp:TextBox ID="TextBox4" runat="server" AutoPostBack="True"
                    ontextchanged="TextBox4_TextChanged"></asp:TextBox>
                <asp:AutoCompleteExtender ID="TextBox4_AutoCompleteExtender" runat="server"
                    DelimiterCharacters=""
                Enabled="True" MinimumPrefixLength="1"  ServicePath="Service1.svc" ServiceMethod="TXTSEARCH" TargetControlID="TextBox4"></asp:AutoCompleteExtender>
            </td>
            <td>
                &nbsp;</td>
        </tr>
    </table>
    <p>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
            DataSourceID="SqlDataSource1">
            <Columns>
                <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False"
                    ReadOnly="True" SortExpression="ID" />
                <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server"
            ConnectionString="<%$ ConnectionStrings:TestConnectionString2 %>"
            SelectCommand="SELECT * FROM [TextboxAutoImpliment]"></asp:SqlDataSource>
    </p>
    <p>

     <asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True"
                   ></asp:TextBox>
                <asp:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server"
                    DelimiterCharacters=""
                Enabled="True" MinimumPrefixLength="1"  ServicePath="Service1.svc" ServiceMethod="GetCountries" OnClientItemSelected="setCompanyMasterID" TargetControlID="TextBox1"></asp:AutoCompleteExtender>
          
        <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
        <asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
          
       </p>
    </form>
</body>
</html>


My Code Behind:-
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;
using System.Configuration;
using System.Threading;
namespace Test
{
    public partial class LINQInsert : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
          
        }

        protected void TextBox4_TextChanged(object sender, EventArgs e)
        {
            DataClasses1DataContext d1 = new DataClasses1DataContext();
            var res = (from result in d1.TextboxAutoImpliments
                       where result.Name.ToLower().StartsWith(TextBox4.Text.ToLower())

                       select new { ID = result.ID }).Take(10);
            foreach (var id in res)
            {
                Label1.Text = id.ToString();
            }
        }

      
       
    }
}

My webService Method:-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Configuration;
using System.Data.SqlClient;
using AjaxControlToolkit;

namespace Test
{
    /// <summary>
    /// Summary description for AutoComplete
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
    // [System.Web.Script.Services.ScriptService]
    public class AutoComplete : System.Web.Services.WebService
    {

        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }

        [System.Web.Services.WebMethod]

        public static string[] GetSuggestions(string prefixText, int count)
        {

            try
            {



                string conStr;

                conStr = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

                string sqlQuery = "SELECT [Name],[ID] FROM [TextboxAutoImpliment] WHERE Name like @Name";



                SqlConnection conn = new SqlConnection(conStr);

                SqlCommand cmd = new SqlCommand(sqlQuery, conn);

                cmd.Parameters.AddWithValue("@Name", prefixText + "%");

                conn.Open();



                SqlDataReader dr = cmd.ExecuteReader();

                List<string> custList = new List<string>();

                string custItem = string.Empty;



                while (dr.Read())
                {

                    custItem = AutoCompleteExtender.CreateAutoCompleteItem(dr[0].ToString(), dr[1].ToString());

                    custList.Add(custItem);

                }



                conn.Close();

                dr.Close();



                return custList.ToArray();



            }

            catch (Exception ex)
            {

                throw ex;

            }

        }

    }
}
My database Look:-

Aftter Running View:-


Dopwnload Source Code From My Code Project Article

 Thanks Shibashish Mohanty

.

ShibashishMnty
shibashish mohanty