Feeds:
Posts
Comments

Hi guys ,

if you need any help in MCA /BCA projects in Asp.net C#  technology

BCA 6th sem Cs-76

MCA 4th Sem  MCS-044 Mini Project

MCA 6 th Sem MCSP-060 Major Projects

project synopsis /Project Report/DFD/ER Diagram/SDLC .

feel free to contact me ramanghantiyala@gmail.com

Contact Nu. 9828499945

 

 

Constructors in C# with Example

*PTR–    Point To Remember

A constructor is a method in the class which gets executed when its object is created is called as constructor.

Constructors can be classified into 5 types

  1. Default Constructor
  2. Parameterized Constructor
  3. Copy Constructor
  4. Static Constructor
  5. Private Constructor

Default Constructor : A constructor without any parameters is called as default constructor.

 Public ConstTest()

{

      //Default Constructor

}

PTR:  every instance of the class will be initialized to same values Not Different values

Parameterized Constructor :A constructor with at least one parameter is called as parameterized constructor.

Public ConstTest (Int X ,Int Y)

{

      //Parameterized Constructor

}

PTR: you can initialize each instance of the class to different values

Copy Constructor: A parameterized constructor that contains a parameter of same class type is called as copy constructor.

Public ConstTest ()

{

      //Default Constructor

}

 

Public ConstTest (ConstTest T )

{

      //Copy Constructor

          // Access The property of T.name

}

PTR: initialize new instance to the values of an existing instance.

Static Constructor : You can create a constructor as static and when a constructor is created as static

Static  ConstTest ()

{

      //Static Constructor

}

PTR: it will be invoked only once for any number of instances of the class and it is during the creation of first instance of the class

Private Constructor :You can also create a constructor as private. When a class contains at least one private constructor

Private  ConstTest ()

{

      //private Constructor

}

PTR: restrict the class from being instantiated

What are extension methods?

What are extension methods?

This method allows us to add a new static method to the existing classes.

Example

class Program
    {
        static void Main(string[] args)
        {
            int x = 3;
            Console.WriteLine(x.factorial());
            Console.ReadLine();
        }
    }
    public static class MyMathExtension
    {
        public static int factorial(this int x)
        {
            if (x <= 1) return 1;
            if (x == 2) return 2;
            else
                return x * factorial(x – 1);
        }
    }
Use Of This

  1.     Extension methods allow existing classes to be extended without relying on inheritance or having to change the class’s source code.
  2.     If the class is sealed than there in no concept of extending its functionality. For this a new concept is introduced i.e. extension methods.
  3.     This feature is important for all developers especially if you would like to use the dynamism of the C# enhancements to be taken place in your classes design.

Important points while using extension methods:

  1.     An extension method must be defined in a top-level static class.
  2.     An extension method with the same name and signature as an instance method will not be called.
  3.     Extension methods cannot be used to override existing methods.
  4.     The concept of extension methods cannot be applied to fields, properties or events.
  5.     Overuse of extension methods is not good style of programming.

encrypt decrypt password asp.net with c#.

Namespace

using System.Text;

private string Encryptdata(string password)
    {
        string strmsg = string.Empty;
        byte[] encode = new byte[password.Length];
        encode = Encoding.UTF8.GetBytes(password);
        strmsg = Convert.ToBase64String(encode);
        return strmsg;
    }

private string Decryptdata(string encryptpwd)
    {
        string decryptpwd = string.Empty;
        UTF8Encoding encodepwd = new UTF8Encoding();
        Decoder Decode = encodepwd.GetDecoder();
        byte[] todecode_byte = Convert.FromBase64String(encryptpwd);
        int charCount = Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
        char[] decoded_char = new char[charCount];
        Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
        decryptpwd = new String(decoded_char);
        return decryptpwd;
    }

string strpassword = Encryptdata(TextBox1.Text); //Enc

string strpassword = Decryptdata(TextBox1.Text); //Dec

pop up window in html5?

<html>
<head>
<style type=”text/css”>
.modalDialog
{
position: fixed;
font-family: Arial, Helvetica, sans-serif;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0,0,0,0.8);
z-index: 99999;
opacity: 0;
-webkit-transition: opacity 400ms ease-in;
-moz-transition: opacity 400ms ease-in;
transition: opacity 400ms ease-in;
pointer-events: none;
}

.modalDialog:target
{
opacity: 1;
pointer-events: auto;
}

.modalDialog > div
{
width: 150px;
position: relative;
margin: 10% auto;
padding: 5px 20px 13px 20px;
border-radius: 10px;
background: #fff;
background: -moz-linear-gradient(#fff, #999);
background: -webkit-linear-gradient(#fff, #999);
background: -o-linear-gradient(#fff, #999);
height: 150px;
}

.close
{
background: #606061;
color: #FFFFFF;
line-height: 25px;
position: absolute;
right: -12px;
text-align: center;
top: -10px;
width: 24px;
text-decoration: none;
font-weight: bold;
-webkit-border-radius: 12px;
-moz-border-radius: 12px;
border-radius: 12px;
-moz-box-shadow: 1px 1px 3px #000;
-webkit-box-shadow: 1px 1px 3px #000;
box-shadow: 1px 1px 3px #000;
}

.close:hover
{
background: #00d9ff;
}
</style>
</head>
<body>
<a id=”openModal1″ href=”#openModal”><span>HTML 5 POP UP</span></a>
<div id=”openModal” class=”modalDialog”>
<div>
<a href=”#close” title=”Close”>X</a>
<h3>
Pop Window
</h3>
This is pop window in html5 without jquery .
<p>
</p>
</div>
</div>
</body>
</html>

  <script src=”http://maps.google.com/maps/api/js?v=3&sensor=false&#8221; type=”text/javascript”></script>   

<script language=”javascript” type=”text/javascript”>

        var map;
        var geocoder;
        function InitializeMap() {

           var latlng = new google.maps.LatLng(0, 0);
            var myOptions =
        {
            zoom: 6,
            center: latlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            disableDefaultUI: true
        };
        map = new google.maps.Map(document.getElementById(“map”), myOptions);
        }

        function FindLocaiton(address1) {
                   
            geocoder = new google.maps.Geocoder();
            InitializeMap();

            var address = address1;
            geocoder.geocode({ ‘address’: address }, function (results, status) {
                if (status == google.maps.GeocoderStatus.OK) {
                    map.setCenter(results[0].geometry.location);
                  var marker = new google.maps.Marker({
                       map: map,
                       position: results[0].geometry.location
                    });

                }
                else {
                    alert(“Geocode was not successful for the following reason: ” + status);
                }
            });

        }
 

</script>

page Desing
<div id=”map”  style=”width:600px; height:400px;”x”>
</div>

<div style=”float: left; width: 100%; margin-bottom: 20px;”>
<div style=”height:48px; padding:0px; line-height:48px; padding-left:68px;” id=”Addedproduct”  runat=”server”>

Find Your Local Stores:
<asp:TextBox ID=”txt_search”  runat=”server” ></asp:TextBox>
&nbsp;

<asp:button type=”Submit” runat=”server”  text=”Search”  style=”border: none;” id=”btn_Search”
onclick=”btn_Search_Click” ></asp:button>
</div>
</div>

Button Coding

 protected void btn_Search_Click(object sender, EventArgs e)
    {
       ClientScript.RegisterStartupScript(this.GetType(), “FindLocaiton”, string.Format(“FindLocaiton(‘{0}’);”, txt_search.Text), true);
    }

 

 

google map in asp.net?

prerequisite:

1)<script src=”http://maps.google.com/maps/api/js?v=3&sensor=false&#8221; type=”text/javascript”></script>

2) Database Structure

S.No Lattitude Longitude Cityname
1 27.19912 73.74092 Nagaur

Javascript Code:

<script src=”http://maps.google.com/maps/api/js?v=3&sensor=false&#8221; type=”text/javascript”></script>

<script type=”text/javascript”>

             var icon = new google.maps.MarkerImage(“http://maps.google.com/mapfiles/ms/micons/blue.png&#8221;,

            new google.maps.Size(32, 32), new google.maps.Point(0, 0),

            new google.maps.Point(16, 32));

        var center = null;

        var map = null;

        var currentPopup;

        var bounds = new google.maps.LatLngBounds();

          var rendererOptions = {

            draggable: true

        };

         var directionsDisplay = new google.maps.DirectionsRenderer(rendererOptions);

        var directionsService = new google.maps.DirectionsService();

        var australia = new google.maps.LatLng(28.64186, 77.29457);

           function addMarker(lat, lng, info) {

                            // alert(“lat=”+lat,+”ln=”+lng,info);

 

            var StoreNAme= lat.split(“{“);      

            var str = StoreNAme[0];

            var n = str.split(“:”);

            lat = n[0];

            lng = n[1];

            info = n[2];

            var pt = new google.maps.LatLng(lat, lng);

            bounds.extend(pt);

           

            var key = n[2];           

            key=key.replace(/ /g,”_”);

//pop box

            info= ‘<div style=”widht:300px;”><div style=”float:left; widht:30%;”><img src=”img_shop.png” style=”width: 57px;” ></div><div style=” widht:70%; margin-top: 3px;”><span>Store Name:</span><b><span>’+StoreNAme[1]+'</span></b><br /><span style=” margin-top: 5px;”>’+n[2]+'</span></div><div style=”float:left;  margin-top: 7px;”><input type=”hidden” id=”sourceAddress” name=”sourceAddress” value=’+key+’><input type=”text” size=”30″ id=”text_search” value=”” name=”txtarch”> <input type=”button” id=’+key+’  onclick=”myFunction(this)” value=”Get Direction” name=”bSearch”></div>’;

           

            var marker = new google.maps.Marker({

                position: pt,

                icon: icon,

                map: map

            });

           

            var popup = new google.maps.InfoWindow({

                content: info,

                maxWidth: 300,

                

            });

 

            google.maps.event.addListener(marker, “click”, function () {

                if (currentPopup != null) {

                    currentPopup.close();

                    currentPopup = null;

                }

                                        

 

                popup.open(map, marker);

                currentPopup = popup;

            });

            google.maps.event.addListener(popup, “closeclick”, function () {

                //map.panTo(center);

                currentPopup = null;

            });

 

            google.maps.event.addListener(directionsDisplay, ‘directions_changed’,                   function () {

                          

                computeTotalDistance(directionsDisplay.directions);

            });

                           

 

        }


        function initMap() {


            map = new google.maps.Map(document.getElementById(“map”), {

                         

                center: new google.maps.LatLng(0, 0),

                zoom: 1,

                mapTypeId: google.maps.MapTypeId.ROADMAP

               /* mapTypeControl: false,

                mapTypeControlOptions: {

                    style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR

                },

                navigationControl: true,

                navigationControlOptions: {

                    style: google.maps.NavigationControlStyle.SMALL

                }*/

            });

                         

            center = bounds.getCenter();

            map.fitBounds(bounds);


        }

        function calcRoute(origin1,destination1) {


              var request = {

                origin: origin1,

                destination:destination1,

               // waypoints: [{ location: ‘jaipur, Rajasthan’ }],

                travelMode: google.maps.TravelMode.DRIVING

            };

            directionsService.route(request, function (response, status) {                  

                         if (status == google.maps.DirectionsStatus.OK) {

                               

                    directionsDisplay.setDirections(response);

                }

                else

                {

                   alert(“Location not Found”);

                }

 

            });

               directionsDisplay.setMap(map);

            directionsDisplay.setPanel(document.getElementById(‘directionsPanel’));

             var menu = document.getElementById(‘km’)

              menu.style.display=”block”;

              

        }

        function computeTotalDistance(result) {

            var total = 0;

            var myroute = result.routes[0];

            for (i = 0; i < myroute.legs.length; i++) {

                total += myroute.legs[i].distance.value;

            }

            total = total / 1000.

            document.getElementById(“total”).innerHTML = total + ” km”;

        }    

      

       function myFunction(obj)

        {     

        var textvalue=document.getElementById(“text_search”).value;

        var sourceAddress=document.getElementById(“sourceAddress”).value;

         sourceAddress=sourceAddress.replace(/_/g,” “);

              if(textvalue !=”)

            {                calcRoute(textvalue,sourceAddress);

            }

            else

            {

                alert(“Please Enter the Destination Address”);

            }    

        }

    </script>

ASPX Page HTML:

<div id=”map”  style=”width:600px; height:400px;”x”>
</div>

//Direction Div

<div id=”directionsPanel” style=”float: left; min-height: 0px; max-height: 432px;
overflow-y: scroll; width: 100%;”>
</div>

//total Distance

<div id=”km” style=”display: none;”>
<p>
Total Distance: <span id=”total”></span>
</p>
</div>

 

ASPX CODE.CS PAGE CODING

Fill data table from database in asp.net

 

First call the initMap() after calling this function addMarker() Will be Called.

if (dataTable.Rows.Count > 0)

        {

             ClientScript.RegisterStartupScript(this.GetType(), “initMap”, string.Format(“initMap();”), true);

            for (int i = 0; i < dataTable.Rows.Count; i++)

            {

                 if (dataTable.Rows[i][“latitude”].ToString() != “” && dataTable.Rows[i][“longitude”].ToString() != “”)

                {

                    string FinalAddress = dataTable.Rows[i][“Address1”].ToString() + “,” + dataTable.Rows[i][“StateName”].ToString() + “{” + dataTable.Rows[i][“StoreName”].ToString();

                     ClientScript.RegisterStartupScript(this.GetType(), “addMarker” + i, string.Format(“addMarker(‘{0}: {1}: {2}’);”, dataTable.Rows[i][“latitude”].ToString(), dataTable.Rows[i][“longitude”].ToString(), FinalAddress.ToString()), true);

                }

             }

        }